I need to make an exe which puts the window "My window" on the foreground and gives the focus to it.
I run my exe from a shell prompt window. Initially, "My window" is open but is behind the shell window.
When I run the program, "My window" is moved to the left top corner of the screen and is resized so
that only the bar is visible. As if SWP_NOSIZE and SWP_NOMOVE were not taken into account.
Moreover, "My window doesn't have the focus.
What did I do wrong ?
Thanks in advance
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const HWND_TOPMOST = -1
Private Const SWP_SHOWWINDOW = &H40
Dim myHandle As Long
myHandle = FindWindow(vbNullString, "My window")
SetWindowPos(myHandle, HWND_TOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW Or SWP_NOSIZE Or SWP_NOMOVE)