Mobile Start menu

Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_CLOSE = &H10
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
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Const SW_SHOWNORMAL = 1
Private Const SWP_SHOWWINDOW = &H40
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const BM_CLICK = &HF5
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long

Private Function GetHwnd(buttonHwnd As Long, MenuHwnd As Long) As Boolean
Dim LhWnd As Long
Dim StartMenuHwnd As Long
LhWnd = FindWindow("Shell_TrayWnd", vbNullString)
buttonHwnd = The FindWindowEx (LhWnd, 0 , "the Button", vbNullString) 
StartMenuHwnd = the FindWindow ( "DV2ControlHost", vbNullString) 
the If StartMenuHwnd = 0 the Then 
    StartMenuHwnd = the FindWindow ( "BaseBar", vbNullString) 
End If
MenuHwnd = StartMenuHwnd 
End Function 

Private Sub the Command1_Click () 
Dim HWND Long AS, bHwnd of As Long 
Dim myRect AS RECT 
GetHwnd bHwnd, hwnd 
SendMessage bHwnd, BM_CLICK, 0 &, 0 & ' start button 
GetWindowRect hwnd, myRect ' theoretically start menu, the start menu is actually visible is a "form" 
'Hwnd ShowWindow, SW_SHOWNORMAL 
Print myRect.Top, myRect.Right ' This place does not seem to add the operation will be a problem. IDE is particularly evident in 
' the SetWindowPos HWND, 0, 200 is, 200 is, 200 is, 350, SWP_SHOWWINDOW 
the MoveWindow HWND, 200 is , 200 is , 220 , 300, True ' can not get its width and height 
End Sub

 

Guess you like

Origin www.cnblogs.com/blogpro/p/11346122.html