ixemul Nan mais sans blague ! ⚡ | Possible avec une API
A mettre de préference dans un module séparé
Code :
- Private 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 FormOnTop(hWindow As Long, bTopMost As Boolean)
- ' Example: Call FormOnTop(me.hWnd, True)
- Const SWP_NOSIZE = &H1
- Const SWP_NOMOVE = &H2
- Const SWP_NOACTIVATE = &H10
- Const SWP_SHOWWINDOW = &H40
- Const HWND_TOPMOST = -1
- Const HWND_NOTOPMOST = -2
-
- wFlags = SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW Or SWP_NOACTIVATE
-
- Select Case bTopMost
- Case True
- Placement = HWND_TOPMOST
- Case False
- Placement = HWND_NOTOPMOST
- End Select
-
- SetWindowPos hWindow, Placement, 0, 0, 0, 0, wFlags
- End Sub
|
A mettre dans l'evennement Load de la forme que tu veux garder en premier plan:
Code :
- Private Sub Form_Load()
- Call FormOnTop(Me.hWnd, True)
- End Sub
|
|