key RETURN to execute a button (NOT to close the Dialog box) 
Author Message
 key RETURN to execute a button (NOT to close the Dialog box)

key RETURN to execute a button (NOT to close the Dialog box)
------------------------------------------------------------
I work with VC 4.2 on an MFC application.
I have now a dialog-box, where users have a lot of work
in an EDIT field. To get more user-speed , I like the ENTER key
to trigger the procedure on a push-button (update/goto next),
but instead the Dialog-box closes.
I deleted already the OK and CANCEL button, but ENTER seems still
to be running OnOK().
 How can I solve my problem ?

Thank's for any advise.

Johannes (medium level MFC experience)
Brussels/Belgium
--
visit my website:"FAQ Win95/Win98/WinNT4 networking" at
" http://www.*-*-*.com/ " (or the link via CIS:
" http://www.*-*-*.com/ ;)
for 140+ pages with FAQs/procedures on cabling, network setup
and trouble-shooting for Ethernet networking and DUN RAS DCC VPN PPTP.

Johannes



Thu, 18 Jan 2001 03:00:00 GMT  
 key RETURN to execute a button (NOT to close the Dialog box)
this KB article explains the solution in detail
How to Disable Default Pushbutton Handling for MFC Dialog
Last reviewed: July 22, 1997
Article ID: Q122489
http://support.microsoft.com/support/kb/articles/q122/4/89.asp

--
-------------------------------------------------------
Rajesh Parikh
Microsoft Certified Solution Developer

-------------------------------------------------------

Quote:

>key RETURN to execute a button (NOT to close the Dialog box)
>------------------------------------------------------------
>I work with VC 4.2 on an MFC application.
>I have now a dialog-box, where users have a lot of work
>in an EDIT field. To get more user-speed , I like the ENTER key
>to trigger the procedure on a push-button (update/goto next),
>but instead the Dialog-box closes.
>I deleted already the OK and CANCEL button, but ENTER seems still
>to be running OnOK().
> How can I solve my problem ?

>Thank's for any advise.

>Johannes (medium level MFC experience)
>Brussels/Belgium
>--
>visit my website:"FAQ Win95/Win98/WinNT4 networking" at
>"http://www.helmig.com" (or the link via CIS:
>"http://ourworld.compuserve.com/homepages/J_Helmig")
>for 140+ pages with FAQs/procedures on cabling, network setup
>and trouble-shooting for Ethernet networking and DUN RAS DCC VPN PPTP.

>Johannes



Thu, 18 Jan 2001 03:00:00 GMT  
 key RETURN to execute a button (NOT to close the Dialog box)
There are a couple things happening here. One is that Enter will
always generate an IDOK. So the trick is not to delete the OnOK
handler, but to have a handler that just does "return". You may have
to do the same for OnCancel if you don't want ESC to close the dialog.

Now you have two choices: you can, instead of making OnOK just return,
do whatever you want the Enter key to do. This is fine if the Enter
key always does the same thing. But if the meaning of the Enter key is
specific to each control, you have to subclass the controls. My own
preference in this case is to have the control send a message to the
parent. The simplest way is to use a user-defined message (I prefer
Registered Window Messages these days), as such:

        void CMyEditControl::OnChar(..., UINT uChar, ...)
            {
             if(uChar == '\r')
                  {
                GetParent()->SendMessage(UWM_SAW_ENTER);
                     return;
                   }
              CEdit::OnChar(...);
             }

Your dialog can then respond to the UWM_SAW_ENTER message and take
whatever action you want. Alternatives to this include sending the
WM_CHAR message to the parent (I tend to avoid this because it can
lead to all sorts of problems; for example, I think in a dialog you
will end up in some confused state as the dialog tries to handle the
WM_CHAR message itself) or sending a WM_COMMAND message up for the
control (it gives you full MFC command routing, but like most attempts
to fake out messages, can cause problems in the future).
                                joe

On Sun, 02 Aug 1998 05:10:08 -0700, "J.Helmig"

Quote:

>key RETURN to execute a button (NOT to close the Dialog box)
>------------------------------------------------------------
>I work with VC 4.2 on an MFC application.
>I have now a dialog-box, where users have a lot of work
>in an EDIT field. To get more user-speed , I like the ENTER key
>to trigger the procedure on a push-button (update/goto next),
>but instead the Dialog-box closes.
>I deleted already the OK and CANCEL button, but ENTER seems still
>to be running OnOK().
> How can I solve my problem ?

>Thank's for any advise.

>Johannes (medium level MFC experience)
>Brussels/Belgium

Joseph M. Newcomer

http://www3.pgh.net/~newcomer


Sun, 21 Jan 2001 03:00:00 GMT  
 key RETURN to execute a button (NOT to close the Dialog box)


Fri, 19 Jun 1992 00:00:00 GMT  
 key RETURN to execute a button (NOT to close the Dialog box)
Hi;

        This is probably a simple question but I can't figure out how to
maximize a view on opening. The program is written as a standard MDI
document / view program. I was able to maximize the mainframe
successfully but no luck with a view.

Any help is appreciated;




Sun, 21 Jan 2001 03:00:00 GMT  
 key RETURN to execute a button (NOT to close the Dialog box)

Quote:
>    This is probably a simple question but I can't figure out how to
>maximize a view on opening.

Dan,

Have a look at Knowledge Base article Q142317 "How to Create a
Minimized/Maximized MDI Child Window".

Dave
----
Address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow up email copies.
http://www.bj.co.uk



Mon, 22 Jan 2001 03:00:00 GMT  
 key RETURN to execute a button (NOT to close the Dialog box)

Quote:

>Hi;

> This is probably a simple question but I can't figure out how to
>maximize a view on opening. The program is written as a standard MDI
>document / view program. I was able to maximize the mainframe
>successfully but no luck with a view.

You can call GetParentFrame()->ShowWindow(SW_SHOWMAXIMIZED); at the end of
your views OnInitialUpdate().

cU
--

   http://djuga.home.ml.org
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Retriever 2.0 is out: http://retriever.home.ml.org

Shareware image viewer, thumbnailer & database
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Tue, 23 Jan 2001 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. PBM: Message box not displayed after main dialog box is closed in MFC dialog-based app

2. Return Key close dialog in EVC

3. Why pressing Enter key closes my dialog box?

4. Dialog Box Closes with Enter Key

5. How to prevent Dialog Box to be closed by pushing enter key

6. Click Esc key to close the modeless dialog box

7. carriage return closes dialog box.

8. carriage return closes dialog box.

9. App closes after Dialog box returns

10. Close button on Dialog Box.

11. Pressing RETURN or ESC key on a Dialog Box

12. Overiding return key in dialog box

 

 
Powered by phpBB® Forum Software