Skip to main content
gamedev.net
🔒 Locked

Whats wrong with this simple code windows message code?

Started by kindfluffysteve May 20, 2003 at 2:48 PM 7 replies 800+ views
Original Post
kindfluffysteve
kindfluffysteve

  
BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
	static int SAGD=0;



	//exit(0);


	switch (Message) 
    { 
		case WM_CLOSE:
			DestroyWindow(hwnd);
		break;
		
		case WM_COMMAND:
		
			switch LOWORD(wParam){
			case LOGON:{
				MessageBox(hwnd, "LOGON", "LOGONMODE", 
						MB_OK | MB_ICONEXCLAMATION);
				return TRUE;
			}
			break;

		}
	
	
 
        // Place message cases here. 

 
        default: 
            return FALSE; 
    } 

}
  
the gui is created by the resource editor thing. When I type something and press return in some edit box - its as though the login button was clicked. looking at resource.h theres no conflict with the defines so I''m really very confused and lost. help me.
CWizard
CWizard
quote:
Original post by kindfluffysteve
When I type something and press return in some edit box - its as though the login button was clicked.
Uh, that is standard behaviour; check any similar dialog box. When you press the enter key, and no other button has the focus, the dialog will automatically send an IDOK command message, which have the default effect of closing the dialog.

You may be able to prevent it by adding a case for IDOK (or the ID of default button), and simply return 0. But, I wouldn''t suggest it; I think you should keep that feature.
scaught
scaught
Make sure your edit control has the ES_WANTRETURN style.
theNestruo
theNestruo
This is not directly related with your problem but I suggest you to:
-Change those "break;" statements into "return 0;".
-Change that "return FALSE;" into "return DefWindow (hwnd, Message, wParam, lParam);".

Just my two (euro)cents.


theNestruo

Syntax error in 2410
Ok
theNestruoSyntax error in 2410Ok
CWizard
CWizard
quote:
Original post by kindfluffysteve
well if thats normal behaviour - it doesnt seem much useful
I find it to be; it allows you handle dialogs quicker. All web forms behave in the same way; enter submits it. In most cases with dialogs, and forms, enter means done.
scaught
scaught
quote:
Original post by CWizard
All web forms behave in the same way; enter submits it. In most cases with dialogs, and forms, enter means done.
With single-line edit boxes, sure. When you''re replying to this post, what happens when you hit enter?


Rick Scott
Rick Scott
quote:
Original post by theNestruo
-Change that "return FALSE;" into "return DefWindow (hwnd, Message, wParam, lParam);".


Don''t do that. Returning TRUE/FALSE is correct for _dialog_ functions. DefWindowProc() is for user-made windows (the ones that were created using CreateWindowEx()).

CWizard
CWizard
quote:
Original post by scaught
With single-line edit boxes, sure. When you''re replying to this post, what happens when you hit enter?
Multi-line edit boxed are obvious exceptions, yes.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.