I'm using the API's FindWindow, ShowWindow, and SetForegroundWindow to determine if a program is already running. If it is, I want to bring it to the top. So far this code works:
hwnd1 = FindWindow(vbNullString, "thecaption"
If hwnd1 = 0 then
' use shell to open the program since it's not already running
Else
' it's a borderless form, so want it maximized
ShowWindow hwnd1, SW_MAXIMIZE
SetForegroundWindow hwnd1
End If
THIS WORKS, and will bring the program with the caption "thecaption" to the top.
My question is, can you detect the window even though the caption is constantly changing? I am changing the caption, ie, showing different ones depending on the time, which form is displayed, etc. Any help would be appreciated. Thanks.
hwnd1 = FindWindow(vbNullString, "thecaption"
If hwnd1 = 0 then
' use shell to open the program since it's not already running
Else
' it's a borderless form, so want it maximized
ShowWindow hwnd1, SW_MAXIMIZE
SetForegroundWindow hwnd1
End If
THIS WORKS, and will bring the program with the caption "thecaption" to the top.
My question is, can you detect the window even though the caption is constantly changing? I am changing the caption, ie, showing different ones depending on the time, which form is displayed, etc. Any help would be appreciated. Thanks.