Jason N. Gaylord
Jason N. Gaylord

Reputation: 8314

Keep Interop Form to Top of VB6 Application

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.

Upvotes: 1

Views: 1501

Answers (1)

Vineet1982
Vineet1982

Reputation: 7918

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

Upvotes: 1

Related Questions