Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 780
  • Last Modified:

How to set default button property at run time in form view application

Hi All,

I have a FormView application,Form view contains 2 buttons(IDOK and IDC_BUTTON_XXX).
i want to change Default button propety at runtime.how to do this in Form view class.

pls tel l me how to do this...?


Thanks in Advance...
0
SRaghunandan
Asked:
SRaghunandan
  • 3
1 Solution
 
AndyAinscowFreelance programmer / ConsultantCommented:
CButton::SetButtonStyle

use this to set the BS_DEFPUSHBUTTON   style
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
That should set the style.  To make certain that an enter key press performs the button action then code such as the following is useful

BOOL CMyPropertyPage1::PreTranslateMessage(MSG* pMsg)
{
    if(pMsg->message == WM_KEYDOWN)
      {
            long nID = ::GetDlgCtrlID(pMsg->hwnd);
            if(pMsg->wParam == VK_RETURN)
            {
                  switch (nID)
                  {
                  case IDC_BTN_SAVE:
                        OnBtnSave();
                        return true;
0
 
SRaghunandanAuthor Commented:
my form view dont have any default button.when i try to set button style as BS_DEFPUSHBUTTON at run time the property is not getting set.what is the reason..?
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
This works by me

      CButton* pButton = (CButton*)GetDlgItem(IDC_BUTTON1);
      UINT i = pButton->GetButtonStyle();
      i |= BS_DEFPUSHBUTTON;
      pButton->SetButtonStyle(i);
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now