Default button && CPropertyPage
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: Default button && CPropertyPage

  1. #1
    Join Date
    Oct 1999
    Uppsala, Sweden

    Default button && CPropertyPage

    I have a propertysheet with several pages in the application I am working with. The problem is that I can not disable/remove the "default" property for the default button on some of the pages (I do not want any of the buttons on the property pages to be default buttons since the default button is defined in the properysheet for all pages). It seems that when there is only one button on the page, that buttons is made the default button automatically.
    If I look in the resource editor, the "default" property is NOT checked for any of the buttons. I have even tried the code snippet below to remove the "default" property if it is set but nothing seems to work.

    In CPropertyPage::OnSetActive()

    pBtn = (CButton*) this->GetDlgItem(IDC_BTN);
    ulStyle = pBtn->GetButtonStyle();
    if(ulStyle & BS_DEFPUSHBUTTON)
    ulStyle -= BS_DEFPUSHBUTTON;
    pBtn->SetButtonStyle(ulStyle, TRUE);

    dwID = this->GetDefID();
    wDefID = LOWORD(dwID);
    wHasDefID = HIWORD(dwID);
    if(wHasDefID == DC_HASDEFID && wDefID != 0)
    // Remove current default button
    CWnd* pWnd = this->GetDlgItem(wDefID);
    ulStyle = ((CButton*)pWnd)->GetButtonStyle();
    ulStyle -= BS_DEFPUSHBUTTON;
    ((CButton*)pWnd)->SetButtonStyle(ulStyle, TRUE);

    Any ideas anyone???


  2. #2
    Join Date
    Apr 2009

    Re: Default button && CPropertyPage

    BOOL CMyPropertyPage::SetActive()
    GetParent()->PostMessage(DM_SETDEFID, ID_OF_DESIRED_BUTTON);
    return CPropertyPage::SetActive();

    Using PostMessage is required in order to delay until after normal processing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a survey!

HTML5 Development Center