[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Default CButton doens't work when created programmatically

Posted on 2007-04-03
3
Medium Priority
?
697 Views
Last Modified: 2013-11-20
When I create a CButton using Create, and I set the style to BS_DEFPUSHBUTTON, the button doesn't receive the button click message when the user hits the enter key.  It generates the OnOK message.  When the button is created using the resource editor and the style is set to default button, everything works correctly.  How do I make a button the default button when creating it programmatically?  Do I have to determine the default myself by handling the DM_GETDEFID message?  Is there a better way?
0
Comment
Question by:kevinbenedict
[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
3 Comments
 
LVL 9

Accepted Solution

by:
Priyesh earned 2000 total points
ID: 18848108
Normally you make a button default by setting the BS_DEFPUSHBUTTON style. If the visual cues doesnt stick, you can try sending a BM_SETSTYLE message to the button.
m_btn.SendMessage(BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE) ;

This is from MSDN documentation of DM_GETDEFID
An application sends a DM_GETDEFID message to retrieve the identifier of the default push button control for a dialog box.
I think you will have to handle DM_GETDEFID.

For this,
ON_MESSAGE(DM_GETDEFID, OnGetDefID)

LRESULT CMyView::OnGetDefID(WPARAM wPar, LPARAM lPar)
{
   return MAKEWPARAM(1200, DC_HASDEFID) ;//1200 is the button id which you want to make default.
}

Somebody else might know a better way here.
0
 
LVL 19

Expert Comment

by:alb66
ID: 18848770
Be sure that no other buttons in the dialog have the BS_DEFPUSHBUTTON style
0
 

Author Comment

by:kevinbenedict
ID: 18851861
This works great in Windows but not on a PocketPC for some reason.  I am using eVC++ and am targeting mobile devices.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

649 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