一个奇怪的现象,个人不知何故。程式中有一句禁止Button的语句,如下:
((CButton*)GetDlgItem(IDC_BUTTON))->EnableWindow(false);
该语句的确是禁止了Button的响应,但是Button没有变灰,请问可能的原因?

解决方案 »

  1.   

    ((CButton*)GetDlgItem(IDC_BUTTON))->EnableWindow(false);
    ================
    应该可以变灰的啊,一般变灰都是这样写
      

  2.   

    不用强制转换的,直接GetDlgItem(IDC_BUTTON)->EnableWindow(false);
    ----------------------------------------
    把ID该一下,估计是ID的问题,比如IDC_BUTTON_TEST,再试试~
      

  3.   


    对啊,自己绘制的和系统带的不是一样么,关键是ID要写正确了,需要类型转换吧,虽然CDialog就派生于CWnd,但是返回类型是CWnd*,
    下边是 MSDN中说的
    CWnd::GetDlgItem
    This method retrieves a pointer to the specified control or child window in a dialog box or other window. The pointer returned is usually cast to the type of control identified by nID. CWnd* GetDlgItem ( 
    int nID ) 
    const; void CWnd::GetDlgItem( 
    int nID, 
    HWND* phWnd ) 
    const; 
      

  4.   

    肯定是ID不对了,估计是是IDC_BUTTON1吧??
      

  5.   

    因为自绘的话,可能自己实现了disable的样式
      

  6.   

    自绘的,你要实现ODS_DISABLED状态样式