Solved

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

Posted on 2004-04-05
5
747 Views
Last Modified: 2013-11-20
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
Comment
Question by:SRaghunandan
  • 3
5 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
CButton::SetButtonStyle

use this to set the BS_DEFPUSHBUTTON   style
0
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
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
 

Author Comment

by:SRaghunandan
Comment Utility
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
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 400 total points
Comment Utility
This works by me

      CButton* pButton = (CButton*)GetDlgItem(IDC_BUTTON1);
      UINT i = pButton->GetButtonStyle();
      i |= BS_DEFPUSHBUTTON;
      pButton->SetButtonStyle(i);
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Unix / Linux grid computing 5 125
notReplace  challenge 53 102
fizzArray2 challenge 1 55
noX challenge 17 75
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video discusses moving either the default database or any database to a new volume.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now