1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xpoint As Long, ByVal ypoint As Long) As Long
Public Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Public Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
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
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub testballade_userform()
With CreateObject("WScript.Shell"): ppx = .RegRead("HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics\AppliedDPI") / 72: End With
With UserForm1
.Show 0
handle_Caption = FindWindow(vbNullString, UserForm1.Caption)
handle_Caption_by_W_f_point = WindowFromPoint((.Left + 5) * ppx, (.Top + 5) * ppx)
handle_interieur = WindowFromPoint((.Left + 30) * ppx, (.Top + 30) * ppx)
Debug.Print "findwindow " & handle_Caption
Debug.Print "windowfrompoint caption " & handle_Caption_by_W_f_point
Debug.Print "windowfrompoint interieur " & handle_interieur
Debug.Print "parent du handle_interieur " & GetParent(handle_interieur)
handle_application = Application.hwnd
SetParent handle_interieur, handle_application
SetWindowPos handle_interieur, 0, (UserForm1.Left - 300) * ppx, (UserForm1.Top * ppx), 300, 300, 0
End With
End Sub |
Partager