zoukankan      html  css  js  c++  java
  • 移动开始菜单

    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 = FindWindowEx(LhWnd, 0, "Button", vbNullString)
    StartMenuHwnd = FindWindow("DV2ControlHost", vbNullString)
    If StartMenuHwnd = 0 Then
        StartMenuHwnd = FindWindow("BaseBar", vbNullString)
    End If
    MenuHwnd = StartMenuHwnd
    End Function
    
    Private Sub Command1_Click()
    Dim hwnd As Long, bHwnd As Long
    Dim myRect As RECT
    GetHwnd bHwnd, hwnd
    SendMessage bHwnd, BM_CLICK, 0&, 0& '开始 按钮
    GetWindowRect hwnd, myRect '理论上是开始菜单,可见开始菜单其实是个“窗体”
    'ShowWindow hwnd, SW_SHOWNORMAL
    Print myRect.Top, myRect.Right'这个地方好象不加个操作就会有问题。在IDE下尤其明显
    'SetWindowPos hwnd, 0, 200, 200, 200, 350, SWP_SHOWWINDOW
    MoveWindow hwnd, 200, 200, 220, 300, True '无法获得其宽度和高度
    End Sub
  • 相关阅读:
    sys:1: RuntimeWarning: coroutine 'Launcher.killChrome' was never awaited
    python 引用对象相等,还是用list.extend()
    python 3.7.4 垃圾,一整天安装那个mitmproxy ,不行,卡在一个破库叫urwid ,说是os.path()为空,换3.8.2安装成功,垃圾3.7.4迟早要完
    python @staticmethod 注解,静态方法,可以省略类里那个self参数
    spring boot 记一次花了两天还是没有解决的奇怪bug(失去所有响应,post不到了,啥反应也没有了)
    Yum常用命令
    Centos安装与配置
    遍历hashmap的6种方法
    Java定时调度
    ElasticSearch的应用
  • 原文地址:https://www.cnblogs.com/blogpro/p/11346122.html
Copyright © 2011-2022 走看看