按TAB顺序枚举窗口中的各个控件
2009-09-17 22:33
204 查看
例1:
void CMyDlg::OnButton7()
{
CWnd *pChild = this->GetWindow(GW_CHILD);
CString s;
while(pChild)
{
pChild->GetWindowText(s);
MessageBox(s);
pChild = pChild->GetWindow(GW_HWNDNEXT);
}
}
例2:
void CSimParDlg::OnButton1()
{
// TODO: Add your control notification handler code here
CWnd *pWnd;
pWnd=GetWindow(GW_CHILD);
while (pWnd!=NULL)
{
if (pWnd-> IsKindOf(RUNTIME_CLASS(CEdit)))
pWnd-> EnableWindow(false);
pWnd=pWnd-> GetNextWindow();
}
}
在对话框中按ctrl+D,编辑各控件的tab值,这样上面程序就会按照tab顺序遍历各个控件
例3:
// 遍历得到页面中的所有Button控件,依次设定其样式和颜色
CWnd* pWnd = GetWindow(GW_CHILD);
char cClassName[255]=...{0};
while(pWnd)
...{
GetClassName(pWnd->GetSafeHwnd(),cClassName,255);//得到控件的类名,主要有Edit,Button,Static等等
if(strcmp(cClassName,"Button") == 0) //是Button控件
...{
CXTButton *pBtn = (CXTButton*) pWnd;
pBtn->SetXButtonStyle(BS_XT_XPFLAT);
pBtn->SetColorFace(BUTTON_BKCOLOR); //按钮背景色
}
pWnd = pWnd->GetWindow(GW_HWNDNEXT);
}
void CMyDlg::OnButton7()
{
CWnd *pChild = this->GetWindow(GW_CHILD);
CString s;
while(pChild)
{
pChild->GetWindowText(s);
MessageBox(s);
pChild = pChild->GetWindow(GW_HWNDNEXT);
}
}
例2:
void CSimParDlg::OnButton1()
{
// TODO: Add your control notification handler code here
CWnd *pWnd;
pWnd=GetWindow(GW_CHILD);
while (pWnd!=NULL)
{
if (pWnd-> IsKindOf(RUNTIME_CLASS(CEdit)))
pWnd-> EnableWindow(false);
pWnd=pWnd-> GetNextWindow();
}
}
在对话框中按ctrl+D,编辑各控件的tab值,这样上面程序就会按照tab顺序遍历各个控件
例3:
// 遍历得到页面中的所有Button控件,依次设定其样式和颜色
CWnd* pWnd = GetWindow(GW_CHILD);
char cClassName[255]=...{0};
while(pWnd)
...{
GetClassName(pWnd->GetSafeHwnd(),cClassName,255);//得到控件的类名,主要有Edit,Button,Static等等
if(strcmp(cClassName,"Button") == 0) //是Button控件
...{
CXTButton *pBtn = (CXTButton*) pWnd;
pBtn->SetXButtonStyle(BS_XT_XPFLAT);
pBtn->SetColorFace(BUTTON_BKCOLOR); //按钮背景色
}
pWnd = pWnd->GetWindow(GW_HWNDNEXT);
}
相关文章推荐
- VC中调整窗口控件的TAB顺序
- MFC学习笔记——CDialog(设置对话框控件的Tab顺序)
- 在VC++中怎样改变控件间的TAB切换顺序?
- ASP.NET Web 服务器控件中的 Tab 键顺序问题
- vc编程 控件的TAB键顺序设置
- 更改MFC 对话框控件的tab顺序
- CWnd中创建控件修改其TAB顺序
- MFC对话框窗口&Tab Control控件
- vc快速设置控件的tab顺序
- 如何控制 VC 中控件间的TAB切换顺序
- VS2005显示所有控件Tab顺序以及调整的方法
- VC如何设置控件Tab顺序
- MFC+控件Tab顺序
- MFC Tab控件子窗口调用父窗口资源方法
- VS2010/MFC编程入门之九(对话框:设置对话框控件的Tab顺序)
- 如何改变VC中控件间的TAB切换顺序
- [转载]如何改变VC中控件间的TAB切换顺序
- MFC调整控件tab顺序
- Tab控件下子对话窗口的按钮不响应消息
- 如何控制 VC 中控件间的TAB切换顺序