CWnd* pwndChild = GetWindow(GW_CHILD);   
        while (pwndChild)
        {      
            //....to do sth.
            pwndChild = pwndChild->GetNextWindow();
        }

如上代码在循环获得窗口所有子控件后,得到的是一个CWnd指针。

一般的判断对象类型的方法:

            if (pwndChild -> IsKindOf (RUNTIME_CLASS( CButton )))
            {
                pwndChild ->EnableWindow(FALSE);
            }

但这里不能这样用,因为这里的类型已经成了CWnd

判断CWnd类型的一个比较笨的方法:

            char NAME[10];
            GetClassName(pwndChild->m_hWnd,NAME,10);
            pwndChild ->EnableWindow(strcmp(NAME,"Button"));

 

这个的问题是,会把标题栏上的系统按钮也禁止掉。

相关文章:

  • 2022-12-23
  • 2022-01-17
  • 2022-12-23
  • 2022-12-23
  • 2021-11-22
  • 2022-01-17
  • 2022-12-23
  • 2021-05-31
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-24
  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
相关资源
相似解决方案