Solved

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

Posted on 2004-04-05
5
755 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
ID: 10755682
CButton::SetButtonStyle

use this to set the BS_DEFPUSHBUTTON   style
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 10755732
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
ID: 10763901
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
ID: 10764133
This works by me

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
deburging in oracle form 12 105
sameEnds challenge 3 180
haveThree challenge 22 121
moto 4g phone enable finger print 4 27
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 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