请问怎么样才能截获PropertySheet的确定、取消的消息???

解决方案 »

  1.   

    IDDomodal()==IDOK
    IDDomodal()==IDCANCEL
      

  2.   

    在propertysheet中,在一般情况,当用户按"cancel",你的propertypage将收到PSN_QUERYCANCEL消息.当用户按"ok"的时候,如果"apply"是enabled的,那么你将收到PSN_APPLY消息.
      

  3.   

    在PropertyPage的派生类中响应 OnOK() OnCancel() OnApply()消息。
      

  4.   

    覆盖CPropertySheet类的OnCommand函数,截获按钮点击消息。实现如下:
    (摘自codeproject)BOOL CMyPropertySheet::OnCommand(WPARAM wParam, LPARAM lParam) 
    {
    // allow message map override
    if (CWnd::OnCommand (wParam, lParam))
       return TRUE;
        
    // crack message parameters
    UINT nID = LOWORD(wParam);
    HWND hWndCtrl = (HWND)lParam;
    int nCode = HIWORD(wParam);
        
    // set m_nModalResult to ID of button, whenever button is clicked
    if (hWndCtrl != NULL && nCode == BN_CLICKED)
    {
       if (::SendMessage(hWndCtrl, WM_GETDLGCODE, 0, 0) &
                         (DLGC_BUTTON|DLGC_DEFPUSHBUTTON))
       {
           LONG lStyle = ::GetWindowLong(hWndCtrl, GWL_STYLE) & 0x0F;
           if (lStyle == BS_PUSHBUTTON || lStyle == BS_DEFPUSHBUTTON ||
                    lStyle == BS_USERBUTTON || lStyle == BS_OWNERDRAW)
           {
                    if (nID == IDOK)
                    {
                            // do whatever you want.
                            return TRUE;
                    }
                    else if (nID == ID_APPLY_NOW)
                    {
                            // do whatever you want.
                            return TRUE;
                    }
                    else if (nID == IDCANCEL)
                    {
                            // do whatever you want.
                            return TRUE;
                    }
                }
            }
        }
        return FALSE;

    }