0
Thanks

A few words of thanks would be greatly appreciated.

Keep Application Window on Top of Other Apps with VB6

In this article we will explain how to keep an application window on top of other applications in VB6.


In a General Module

Public 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 Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Public Const SWP_NOACTIVATE = &H10
Public Const SWP_SHOWWINDOW = &H40
Public Const SWP_NOMOVE = 2
Public Const SWP_NOSIZE = 1

In the Form

Private Sub Form_Load() 
Dim R as long
R = SetWindowPos(SheetName.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
end sub

Calling the Function

The function must call upon the activation of the form. It will allow the program to resume the function if the form is selected (as the function may be used by other application).
Private Sub Form_Activate() 
Dim R as long
R = SetWindowPos(SheetName.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
end sub

Removing Priority

Private sub SuppPriority() 
Dim R as long
R= SetWindowPos(NomFeuille.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
End sub

Photo: Unsplash
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Related

This document, titled « Keep Application Window on Top of Other Apps with VB6 », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).

0 Comments