vb中如何获得所有的窗口语柄
2个回答
展开全部
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 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 Sub Command1_Click()
Dim i As Long
i = FindWindowEx(0, 0, vbNullString, "TestWindow")
Do Until i = 0
SetWindowPos i, Me.hwnd, 0, 0, 640, 480, 0
i = FindWindowEx(0, i, vbNullString, "TestWindow")
Loop
End Sub
以上代码是搜索慎唤察所有标题为“TestWindow”的窗口,并把它们移到桌面左上角,大小设置为640*480,是精简得不能再简的代码了,只用了两个API函数。你在此基础上修改一下就行了。
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 Sub Command1_Click()
Dim i As Long
i = FindWindowEx(0, 0, vbNullString, "TestWindow")
Do Until i = 0
SetWindowPos i, Me.hwnd, 0, 0, 640, 480, 0
i = FindWindowEx(0, i, vbNullString, "TestWindow")
Loop
End Sub
以上代码是搜索慎唤察所有标题为“TestWindow”的窗口,并把它们移到桌面左上角,大小设置为640*480,是精简得不能再简的代码了,只用了两个API函数。你在此基础上修改一下就行了。
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询