The FindWindow function retrieves a handle to the top-level window whose class name and window name match the specified strings. This function does not search child windows. This function does not perform a case-sensitive search.Tpage虽然不是最顶层窗口,但是是显示出来的主窗口。
查找到Tpage的窗口句柄wndTpage后,可以如下操作:
HWND hwnd1 = ::GetWindow(wndTpage,GW_CHILD);//查找子窗口
HWND hwnd2 = ::GetWindow(hwnd1,GW_CHILD); //查找子窗口
HWND hwnd3 = ::GetWindow(hwnd2,GW_CHILD); //查找子窗口,得到Edit控件句柄。
如果hwnd2窗口内是有多个子控件,可以继续如下查找:
char strBuff[256];
hChildWnd=hwnd3;
while(hChildWnd!=NULL){
::GetClassName(hChildWnd,strBuff,256);
hChildWnd=::GetNextWindow(hChildWnd,GW_HWNDNEXT);//查找下一个子控件
}
查找到Tpage的窗口句柄wndTpage后,可以如下操作:
HWND hwnd1 = ::GetWindow(wndTpage,GW_CHILD);//查找子窗口
HWND hwnd2 = ::GetWindow(hwnd1,GW_CHILD); //查找子窗口
HWND hwnd3 = ::GetWindow(hwnd2,GW_CHILD); //查找子窗口,得到Edit控件句柄。
如果hwnd2窗口内是有多个子控件,可以继续如下查找:
char strBuff[256];
hChildWnd=hwnd3;
while(hChildWnd!=NULL){
::GetClassName(hChildWnd,strBuff,256);
hChildWnd=::GetNextWindow(hChildWnd,GW_HWNDNEXT);//查找下一个子控件
}
解决方案 »
- StretchDIBits函数的使用,没有把接收到的bmp图片显示到界面上
- _HRESULT_TYPEDEF_()表示什么意思?
- 在教育网和公网之间点对点传输非常慢,大家给点建议怎么办
- VC编辑框控件变量和String类型的变量有什么不同?
- PS界面模仿问题集__怎样实现图层窗口?
- 百无头绪————隔着几层对话框怎么设置OnTimer()
- 关于CComboBox的问题
- 紧急求助!!!在用vc编程时,我不知道怎么添加一个新类。是在view中添加还是直接在头文件中自己写代码。望各位大虾指点!!
- IHTMLSelectElement::options得到所有option的集合之后,怎样遍历定位目标选项,然后设置为selected?
- DLL的回调函数报错
- 得到路径问题
- 用vc做基于EXCEL的加工数据综合处理
HWND hwndParent, // handle to parent window
HWND hwndChildAfter, // handle to a child window
LPCTSTR lpszClass, // pointer to class name
LPCTSTR lpszWindow // pointer to window name
);
hwndChildAfter
Handle to a child window. The search begins with the next child window in the Z order. The child window must be a direct child window of hwndParent, not just a descendant window.
If hwndChildAfter is NULL, the search begins with the first child window of hwndParent.
Note that if both hwndParent and hwndChildAfter are NULL, the function searches all top-level and message-only windows.
用FindWindowEx遍历子窗口,在获取了第一个子窗口句柄后拿它做为第二个参数,找到第二个子窗口,然后以此类推遍历下去。