Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Setting default button programmatically

Posted on 1998-12-29
6
Medium Priority
?
250 Views
Last Modified: 2013-11-20
During program execution, when a certain edit box gets the focus in a dialog, I want that to make a specific button become the default button, so that if the user presses ENTER while the edit box has focus, the button is pressed. I don't want this button to be the default button to start out with, just when this edit box is in focus.  Then the default button can get changed back to the original one, or not - doesn't really matter.
0
Comment
Question by:aaronl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 6

Accepted Solution

by:
thresher_shark earned 210 total points
ID: 1326938
Answer coming...
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1326939
To do what you ask, use this:

CButton your_button; // Attach this to your button using classwizard

.

your_button.SetButtonStyle (BS_DEFPUSHBUTTON); // This will set it as the default button.

---
First you want to attach a variable of type CButton to your button in the ClassWizard.  Then, place the "SetButtonStyle" code at the point you want to change it to the default button.  If you want to change the default button status back to another button, attach another variable of type CButton to the other button and do the same thing.  If you have additional questions, please feel free to ask.  Thanks!
0
 

Author Comment

by:aaronl
ID: 1326940
Thanks-

only thing to add is that you have to explicitly remove the previously marked default
button....

A
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:thresher_shark
ID: 1326941
Oh, whoops :-)  I didn't even know anything about this function until I looked searched for it the help.  Anyway, I am glad you have it working.
0
 

Author Comment

by:aaronl
ID: 1326942
hey, all apologies for the "good" score as well... I didn't know the system, and someone told me that was worth an excellent.
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1326943
Oh, that?  It doesn't matter to me as long as you have a solution.  I have enough points as it is :-)
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

705 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