I'm using the InteropFormsToolkit version 2.1. I'm trying to make sure that when a .NET form loads from an event being thrown on the VB6 form, that the .NET form can stay on top. I've tried many things and can't get anything to work. I've tried everything from z-index, to adding a managed call into User32.dll to push it to the forefront, etc.
Any ideas are appreciated.
In vb6 you can use as:
Private Sub Form_Load()
OnTopMe Me, True
End Sub
and following code in module
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
Public Sub OnTopMe(FormID As Object, onTop As Boolean)
If onTop = True Then SetWindowPos FormID.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
If onTop = False Then SetWindowPos FormID.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End Sub
I don't know about how to do it in .Net
Create a separate module and paste the second part of above code in it and what ever the form you want to show on top on event of on_load write "OnTopMe Me, True", Me here means the form which you want to show on top and thus change change it which your form name true to show on top and false to not show on to - Vineet1982 2012-05-09 14:11