Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

brain21

TextBox Behavior

This topic is 5796 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m having a little problem with my application. This is what I have: Visual C++ 6.0 MFC Dialog Based Application My main Dialog calls another dialog: CMyDialog dlgNewDialog; dlgNewDialog.DoModal(); My new dialog has an Exit button and a textbox. When I enter some text in the textbox and press ENTER the dialog closes. Almost like it is calling the Exit Button. I have other objects on the dialog and the textbox is the first in the tab order and the exit button is the last in the tab order. I can''t figure out why it''s doing this. Brain21

Share this post


Link to post
Share on other sites
Advertisement
Sounds like your close button have focus. You can set focus to another controller when the dialog shows up.

Like this:


  

BOOL CALLBACK DlgProc(HWND hwnd, UINT uiMessage, WPARAM wParam, LPARAM lParam)
{
switch(uiMessage)
{
case WM_INITDIALOG:
SetFocus(GetDlgItem(hwnd, IDC_TEXTBOX_EB));
break;

...

Share this post


Link to post
Share on other sites
When my dialog pops-up, the text box has focus. But when I type something in and press ENTER the dialog exits.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
set the "Want return" style of the edit control.

Share this post


Link to post
Share on other sites
What I discovered is that when I press ENTER on the text box, the OnOK() function gets called. What is up with that??
And the "want return" option does not help. Is there a default peice of code somewhere that gets galled when I press ENTER??

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
is your edit control specified as multi-line? if not, then "want return" will not work. if it''s single line then you might try subclassing the edit control window and "eat" the enter key when received via WM_KEYDOWN, i.e., don''t pass it on to DefWindowProc.

but all of this is going against standard usage anyway. the normal change focus key is TAB, not ENTER.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
and yes, there''s a "default piece of code" that gets executed when you press ENTER on a dialog box. that''s also standard for "ok i''m done now, please close this dialog, accepting all changes i have made." just like ESC is standard for "ok i''m done now, please close this dialog and undo all of the changes i have made." it''s just the way standard Windows dialog boxes have always worked.

Share this post


Link to post
Share on other sites
Change the tab order on the dialog template (Ctrl+D) so that the OK button is not the next control after the edit box. I dunno if this''ll work if you only have 1 or 2 controls tho

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
tab order has nothing to do with it. this is standard behavior for a Windows dialog box.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!