怎么取一个对话框的子控件集合

蟾宫伐桂 2005-08-29 03:17:22
我想取一个第三方程序的主窗口中所有的控件,要怎么办?
...全文
107 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
vcmute 2005-09-03
  • 打赏
  • 举报
回复
GetDlgCtrlID
The GetDlgCtrlID function retrieves the identifier of the specified control.

int GetDlgCtrlID(
HWND hwndCtl // handle to control
);
  • 打赏
  • 举报
回复
通过窗口的句柄用GetWindowLong可以得到控件窗口的ID
蟾宫伐桂 2005-09-03
  • 打赏
  • 举报
回复
多谢楼上各位, 不过我的意思没表达清楚,我是想说怎么取每一个控件的ID, 就是设计时写死的ID, 不是运行时的hwnd.
bobob 2005-08-29
  • 打赏
  • 举报
回复
功能:枚举给定窗口的所有层子窗口
#include <windows.h>
#include <STDIO.H>
BOOL myEnumWindow(HWND hwnd);
int main()
{
myEnumWindow(your hwnd);//这里传入第三方窗口的句柄
return 0;
}

BOOL myEnumWindow(HWND inHwnd)
{
char szText[256];

HWND hwndAfter = NULL;
while(hwndAfter = ::FindWindowEx(inHwnd,hwndAfter,NULL,NULL))
{
memset(szText,0,256);
::SendMessage(hwndAfter,WM_GETTEXT,(WPARAM)256,(LPARAM)szText);
printf("%s\t",szText);
myEnumWindow(hwndAfter);
}
return 1;
}
Kudeet 2005-08-29
  • 打赏
  • 举报
回复
GetWindow is ok
lixiaosan 2005-08-29
  • 打赏
  • 举报
回复
EnumChildWindows Function

The EnumChildWindows function enumerates the child windows that belong to the specified parent window by passing the handle to each child window, in turn, to an application-defined callback function. EnumChildWindows continues until the last child window is enumerated or the callback function returns FALSE.

Syntax

BOOL EnumChildWindows(

HWND hWndParent,
WNDENUMPROC lpEnumFunc,
LPARAM lParam
);
everandforever 2005-08-29
  • 打赏
  • 举报
回复
EnumChildWindows

15,980

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧