Is This Content Helpful?
We're glad to know this article was helpful.
Users creating an ActiveX DLL will occasionally want to load a Visual Basic form as part of their application. The form, when first displayed, will appear in front of the parent application. By default, the Visual Basic form will then be repositioned behind ArcMap or ArcCatalog when a user interacts with ArcMap's or ArcCatalog's GUI.
By following the steps below, the Visual Basic form will always stay on top of the parent application.
You can customize even more by making direct calls to SetWindowPos. For more information on SetWindowPos, visit Microsoft MSDN through the link below.
' WINDOW POSITIONING
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
' SetWindowPos Flags
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOZORDER = &H4
Public Const SWP_NOREDRAW = &H8
Public Const SWP_NOACTIVATE = &H10
Public Const SWP_FRAMECHANGED = &H20
Public Const SWP_SHOWWINDOW = &H40
Public Const SWP_HIDEWINDOW = &H80
Public Const SWP_NOCOPYBITS = &H100
Public Const SWP_NOOWNERZORDER = &H200
Public Const SWP_DRAWFRAME = SWP_FRAMECHANGED
Public Const SWP_NOREPOSITION = SWP_NOOWNERZORDER
Public Const FLAGS As Long = SWP_NOMOVE Or SWP_NOSIZE
Public Const HWND_TOP = 0
Public Const HWND_BOTTOM = 1
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Public Sub SetWin_NOTOPMOST(hWnd As Long)
SetWindowPos hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS
Public Sub SetWin_TOPMOST(hWnd As Long)
SetWindowPos hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS