Hello.
I have 2 desktop programms..I will call them P1 and P2.
So, P1 launches P2 as a process. However, at some point I want to be able to show a window in P2.
My problem was that this window, when called, was showing correctly placed, in the middle of the screen, but in the back of P1.
So, in order to show it as the top most window, above all others applications running on my computer, I used the windows API:
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_NOACTIVATE = &H10
Const SWP_SHOWWINDOW = &H40
<DllImport("user32.dll", CharSet:=CharSet.Auto, _ CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function SetWindowPos(ByVal hWnd As IntPtr, 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 Boolean
End Function
And then in the form Activated event, I have called my new function:
Dim b As Boolean = SetWindowPos(Me.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE)
Now the window shows on top of all other, but it is placed in the top left corner of the screen, resized to much small dimentions, that I cannot even see the controls on it.
Could you please indicate some tips, some solutions?
Thank you in advance.