Partager via


CPropertySheet::PressButton

Simulates the choice of the specified button in a property sheet.

void PressButton( 
   int nButton  
);

Parameters

  • nButton
    nButton : Identifies the button to be pressed. This parameter can be one of the following values:

    • PSBTN_BACK   Chooses the Back button.

    • PSBTN_NEXT   Chooses the Next button.

    • PSBTN_FINISH   Chooses the Finish button.

    • PSBTN_OK   Chooses the OK button.

    • PSBTN_APPLYNOW   Chooses the Apply Now button.

    • PSBTN_CANCEL   Chooses the Cancel button.

    • PSBTN_HELP   Chooses the Help button.

Remarks

See PSM_PRESSBUTTON for more information about the Windows SDK Pressbutton message.

A call to PressButton will not send the PSN_APPLY notification from a property page to the framework. To send this notification, call CPropertyPage::OnOK.

Example

// Simulate the selection of OK and Cancel buttons when Alt+K and 
// Alt+C are pressed.  CMyPropertySheet is a CPropertySheet-derived  
// class.
BOOL CMyPropertySheet::PreTranslateMessage(MSG* pMsg) 
{
   if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
   {
      BOOL altkey = GetKeyState(VK_MENU) < 0;
      if (altkey)
      {
         BOOL handled = TRUE;
         switch(toupper((int)pMsg->wParam))
         {
         case 'C':                     // for Alt+C - Cancel button
            PressButton(PSBTN_CANCEL);   // or EndDialog(IDCANCEL); 
            break;

         case 'K':                     // for Alt+K - OK button
            PressButton(PSBTN_OK);      // or EndDialog(IDOK); 
            break;

         default:
            handled = FALSE;
         }

         if (handled)
            return TRUE;
      }
   }

   return CPropertySheet::PreTranslateMessage(pMsg);
}

Requirements

Header: afxdlgs.h

See Also

Reference

CPropertySheet Class

Hierarchy Chart