我用findwindow()得到了一个程序窗口的句柄,但是用findwindowex()无法获得该窗口中,一个caption为“安装”的按钮的句柄,不知错在哪里,望高手指教。(该按钮上除了有“安装”二字外,还有一幅图案)
程序如下:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Any, ByVal lpsz1 As Any, ByVal lpsz2 As String) As Longhwndinstall = FindWindow(0&, "installwatch pro 2.5c - [default.iwc]")
hwndinstall = FindWindowEx(hwndinstall, 0&, 0&, "安装")
程序如下:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Any, ByVal lpsz1 As Any, ByVal lpsz2 As String) As Longhwndinstall = FindWindow(0&, "installwatch pro 2.5c - [default.iwc]")
hwndinstall = FindWindowEx(hwndinstall, 0&, 0&, "安装")
解决方案 »
- 绘制二次曲线A*x*x+B*x+C=0(A不等于0),A、B和C值任意
- 请教高手!!!关于shockwaveFlash控件的问题?
- datagrid控件,按着ctrl键,再单击DATAGRID控件的最左边可以多选,或取消选择。那请问在其他事件时怎样判断某一行是选择的?
- datacombo控件,如何使用键盘的"下方向键"选择下拉列表的内容?
- vba中的转义字符是什么?我想要做字符串操作。
- 怎样在程序里直接执行bat批处理文件
- 正在做毕业设计,Fortran和VB怎么结合起来?怎么在VB中调用Fortran?
- 小弟有一小问题请大家帮忙????好急呀!!!马上给分
- 我的进销存管理系统
- 怎样在程序里面控制传真机
- 不懂这个 Public Const WM_LBUTTONUP = &H202
- 如何在click和dbclick事件中判断鼠标按键值
【VB声明】
Private Declare Function WindowFromPoint Lib "user32" Alias "WindowFromPoint" (ByVal xPoint As Long, ByVal yPoint As Long) As Long【说明】
返回包含了指定点的窗口的句柄。忽略屏蔽、隐藏以及透明窗口 【返回值】
Long,包含了指定点的窗口的句柄。如指定的点处没有窗口存在,则返回零 【参数表】
xPoint --------- Long,x点值 yPoint --------- Long,y点值示例:
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function ExtTextOut Lib "gdi32" Alias "ExtTextOutA" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal wOptions As Long, ByVal lpRect As Any, ByVal lpString As String, ByVal nCount As Long, lpDx As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetTextExtentPoint32 Lib "gdi32" Alias "GetTextExtentPoint32A" (ByVal hdc As Long, ByVal lpsz As String, ByVal cbString As Long, lpSize As POINTAPI) As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim Pt As POINTAPI, mWnd As Long, WR As RECT, nDC As Long
Dim TextSize As POINTAPI, CX As Long, CY As Long
'Get the current cursor position
GetCursorPos Pt
'Get the window under the cursor
mWnd = WindowFromPoint(Pt.X, Pt.Y)
'Get the window's position
GetWindowRect mWnd, WR
'Get the window'zs device context
nDC = GetWindowDC(mWnd)
'Get the height and width of our text
GetTextExtentPoint32 nDC, "Hello !", Len("Hello !"), TextSize
For CX = 1 To WR.Right - WR.Left Step TextSize.X
For CY = 1 To WR.Bottom - WR.Top Step TextSize.Y
'Draw the text on the window
ExtTextOut nDC, CX, CY, 0, ByVal 0&, "Hello !", Len("Hello !"), ByVal 0&
Next
Next
End Sub
Private Sub Form_Paint()
Me.CurrentX = 0
Me.CurrentY = 0
Me.Print "Click on this form," + vbCrLf + "Hold the mouse button," + vbCrLf + "drag the mouse over another window," + vbCrLf + "release the mouse button" + vbCrLf + "and see what happens!"
End Sub
我想获得"installwatch"的下一级子窗口句柄,就是点击"installwatch"上的一个按钮后弹出的窗口,该窗口的标题是"设置安装过程中""需要""监视的内容",可是不成功,望继续指正.Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Any, ByVal lpsz1 As Any, ByVal lpsz2 As String) As Long
hwndnext = FindWindowEx(hwndinstall, 0&, 0&, "设置安装过程中""需要""监视的内容")