Dialog1里面有个按钮button IDC_BUT_DATADDEX2;我想在Dialog2中判断是否灰化,加个头文件可以吗?if(GetDlgItem(IDC_BUT_DATADDEX2)->IsWindowEnabled() == TRUE)

解决方案 »

  1.   

    头文件,不管运行时什么事,你那两个dialog是同一个进程么?
    是同一个工程下的么?GetDlgItem(IDC_BUT_DATADDEX2)这个函数必须得指明是哪个hwnd才能取出相应的button.
      

  2.   

    你只需要在Dialog2中声明一个Dialog1的指针就可以了,当然你要在合适的将用Dialog1的地址传给Dialog2中的这个指针,用这个指针就可以去查看和操作Dialog1中的控件。
      

  3.   

    直接另一个对话框类增加一个查询函数,IsEnable(),然后你Dialog1获取Dialog2的对象,然后调用这个函数来查询
      

  4.   

    1>e:\documents and settings\qcc\qcc\insertdialog.h(100) : error C2146: 语法错误 : 缺少“;”(在标识符“qcc”的前面)
    1>e:\documents and settings\qcc\qcc\insertdialog.h(100) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
    1>e:\documents and settings\qcc\qcc\insertdialog.h(100) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
    1>e:\documents and settings\qcc\qcc\insertdialog.cpp(614) : warning C4129: “s”: 不可识别的字符转义序列
    1>QCC.cpp
    1>e:\documents and settings\qcc\qcc\insertdialog.h(100) : error C2146: 语法错误 : 缺少“;”(在标识符“qcc”的前面)
    1>e:\documents and settings\qcc\qcc\insertdialog.h(100) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
    1>e:\documents and settings\qcc\qcc\insertdialog.h(100) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
    1>QCCDlg.cpp
    1>e:\documents and settings\qcc\qcc\insertdialog.h(100) : error C2146: 语法错误 : 缺少“;”(在标识符“qcc”的前面)
    1>e:\documents and settings\qcc\qcc\insertdialog.h(100) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
    1>e:\documents and settings\qcc\qcc\insertdialog.h(100) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
    1>SelectDialog.cpp
    1>e:\documents and settings\qcc\qcc\insertdialog.h(100) : error C2146: 语法错误 : 缺少“;”(在标识符“qcc”的前面)
    1>e:\documents and settings\qcc\qcc\insertdialog.h(100) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
    1>e:\documents and settings\qcc\qcc\insertdialog.h(100) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
      

  5.   

    HWND   FindWindowEx(   
          HWND   hwndParent,             //   父窗口的句柄   
          HWND   hwndChildAfter,     //   得到的子窗口的句柄   
          LPCTSTR   lpszClass,         //   子窗口类名   
          LPCTSTR   lpszWindow         //   子窗口标题   
      );   
     上面的这个函数可以通过父窗口的句柄取得子窗口的句柄,后面的两个参数可以选用其中之一另一个设置成NULL即可!   
    如果父窗口的句柄不知则可用下面的函数来找到相应的父窗口的句柄:
      HWND   FindWindow(   
          LPCTSTR   lpClassName,     //   主窗口的类名   
          LPCTSTR   lpWindowName     //   窗口标题   
      );
    得到句柄后就可以调用GetDlgItem函数了
      

  6.   

    Dialog1头文件已经包含了Dialog2了。
    Dialog2中声明Dialog1的声明对象不行的呀
      

  7.   

    直接用sdk的函数,传进dlg1的handle
    GetDlgItem
    The GetDlgItem function retrieves the handle of a control in the specified dialog box. HWND GetDlgItem(
      HWND hDlg,       // handle of dialog box
      int nIDDlgItem   // identifier of control
    );
      

  8.   

    1、你在调用前要获得dlg1的句柄。方法很多,比如你可以在dlg2的类成员里定义dlg1的指针变量。然后通过GetSafeHwnd。或者自定义消息什么的
    2、然后把Hwnd作为第一个参数,按钮ID作为第二个参数,就得到按钮的Hwnd
    3、FromHandle函数获得按钮的CWnd指针
    4、IsWindowEnabled
      

  9.   

    1、你的:GetDlgItem(IDC_BUT_DATADDEX2) 含义是 this->GetDlgItem(IDC_BUT_DATADDEX2),这样肯定不行。
    2、应该这样:在两个dlg中相互保留对方的指针,这样就可以访问了。
        如: 在dlg1中访问dlg2中控件可以这样:pDlg2->GetDlgItem(IDC_BUT_DATADDEX2)。
      

  10.   

    1>e:\documents and settings\qcc\qcc\insertdialog.cpp(489) : error C2819: “CQCCDlg”类型没有重载成员“operator ->”
    1>        e:\documents and settings\qcc\qcc\qccdlg.h(22) : 参见“CQCCDlg”的声明
    1>        是要改用“.”吗?
    1>e:\documents and settings\qcc\qcc\insertdialog.cpp(489) : error C2232: “->CWnd::GetDlgItem”: 左操作数有“class”类型,使用“.”
    1>e:\documents and settings\qcc\qcc\insertdialog.cpp(489) : error C2227: “->IsWindowEnabled”的左边必须指向类/结构/联合/泛型类型
      

  11.   

    CQCCDlg qcc;
    if ((qcc->GetDlgItem(IDC_BUT_DATADDEX2)->IsWindowEnabled()) == TRUE)
      

  12.   

    发错了,不好意思哈,后来才发现了,修改下:用IsDlgButtonChecked试下
      

  13.   

    声明一个CString记录ID回传下就行
      

  14.   

    IsWindowEnabled()这个是一CWnd的函数
    也就是你只要得到控件的窗口句柄,再用fromhandle构造一个CWnd就可以用这个函数了.