ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VB.NET - Showing a form from a thread (https://www.excelbanter.com/excel-programming/370724-vbulletin-net-showing-form-thread.html)

inf

VB.NET - Showing a form from a thread
 

I've got an excel plug-in in which I spin off a thread to do some work

Dim testThread As New System.Threading.Thread(AddressOf
testObject.testMethod)
testThread.Start()


That delegate method attempts to create and show a form:

Private Sub testMethod()
Dim testForm As New Form()
testForm.Size = New System.Drawing.Size(300, 300)
testForm.Text = "Test Form 1"
testForm.ShowInTaskbar = True
testForm.Show()
End Sub


This is pretty simple, and appears to work- the thread starts
correctly, and the delegate testMethod is called. However, when the
form is "shown", in Excel it briefly blinks onto the screen then
dissapears. It doesn't show up on the taskbar, ether.

I have tried the Enabled and Visible properties, and the Focus() and
Activate() methods of the System.Windows.Forms.Form testForm object,
but none seem to change this behavior.

Does anyone have any ideas for why this would act this way?


--
inf
------------------------------------------------------------------------
inf's Profile: http://www.excelforum.com/member.php...o&userid=37676
View this thread: http://www.excelforum.com/showthread...hreadid=572844



All times are GMT +1. The time now is 04:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com