I need to change the property of an opening form (just change one command button from disable to enable) in the background thread. In the background thread, I search if this form is opened, if it is then change the command button1 in this form to enable otherwise do nothing (pretty simple).
the part of code I use in my background thread to do this is
Dim myform As New Form2
Dim myhwnd As Long
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName _
As String, ByVal lpWindowsName As String) As Long
myhwnd = FindWindow(vbNullString, "Form2")
if myhwnd <> 0 Then
myform.hwnd = myhwnd
myform.Command1 = True
in above code, I was thinking to assign myhwnd to a new form2 then to hadle the openning form2... But I failed in the line "myform.hwnd = myhwnd" which give me compile error: Function or interface marked as restricted, or the function use an Automation type not supported in Visual Basic" .
I am kind of stuck here. Need your guys hand! Any hint about how to handle the property of a openning form after using findwindow api to get the handle is highly appreciated. Any recommendation to a good web site which give me knowledge in this area is also highly appreciated!
Many thanks in advance!