Option Explicit
Private Declare Function GetActiveWindow Lib "user32.dll" () As Long
Private Declare Function SetWindowPos Lib "user32.dll" (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
Private Const HWND_TOPMOST = -1
Private Const SWP_NOMOVE = &H2
Private Sub UserForm_Click()
Dim hwnd As Long
Dim lngWidth As Long
Dim lngHeight As Long
lngWidth = 45
lngHeight = 45
hwnd = GetActiveWindow()
SetWindowPos hwnd, HWND_TOPMOST, 0, 0, lngWidth, lngHeight, SWP_NOMOVE
End Sub
'Written: August 01, 2009
'Author: Leith Ross
'Summary: Removes the Titlebar and thick border around a UserForm.
'Returns the Window Handle of the Window that is accepting User input.
Public Declare Function GetForegroundWindow Lib "user32.dll" () As Long
Private Declare Function GetWindowLong _
Lib "user32.dll" _
Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong _
Lib "user32.dll" _
Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Sub RemoveFrame()
Dim Bitmask As Long
Dim hwnd As Long
Dim WindowStyle As Long
Const GWL_STYLE As Long = (-16)
Const WS_DLGFRAME As Long = &H400000
hwnd = GetForegroundWindow
WindowStyle = GetWindowLong(hwnd, GWL_STYLE)
Bitmask = WindowStyle And (Not WS_DLGFRAME)
Call SetWindowLong(hwnd, GWL_STYLE, Bitmask)
End Sub
Option Explicit
Private Declare Function GetActiveWindow Lib "user32.dll" () As Long
Private Declare Function SetWindowPos Lib "user32.dll" (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
Private Const HWND_TOPMOST = -1
Private Const SWP_NOMOVE = &H2
Private Sub UserForm_Activate()
Dim hwnd As Long
Dim lngWidth As Long
Dim lngHeight As Long
RemoveFrame
lngWidth = 25
lngHeight = 25
hwnd = GetActiveWindow()
SetWindowPos hwnd, HWND_TOPMOST, 0, 0, lngWidth, lngHeight, SWP_NOMOVE
End Sub
Private Sub UserForm_Click()
Unload Me
End Sub
Je suppose que la finalité est d'obtenir une barre d'outils personnalisée OU d'afficher un Trombinoscope (???).Avec les API, oui , mais dans quel but ??