Message Box appears twice - Win32

New to the Win32 API, I have finally been able to register and create a main window with some children. I've even been able to name my children (use their HMENU parameter in CreateWindowEx), so that I can receive messages from them.

My issue is that I seem to be getting two messages. I don't want to embaress myself too much, so I won't paste too much code:
1
2
3
4
5
6
7
8
9
10
11
12
13
// Things that come before

	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		case IDS_EDIT01:
			MessageBox(NULL, NULL, NULL, NULL);
			break;

// Things that come after 


So, IDS_EDIT01 is the name of my edit box. I'm taking this step-by-step, and my first attempt is "if the edit box is clicked, post a message box". And it does. The problem is that it posts two message boxes.

Is someone familiar with this and knows what might be going wrong? Perhaps when I click on the edit box I am also clicking on the main window. How does one click go through a switch case twice?

I could paste more code, but I'm not even sure what to paste.

I think you should paste more of your WndProc loop, or whatever you called it ( I mean the Message Handling loop )
EDIT: Oh wait, it's a EditBox, and not a button-as of now i cannot help you, i will look around for a bit.
RE-EDIT: Look at this: http://msdn.microsoft.com/en-us/library/windows/desktop/bb775458(v=vs.85).aspx
Especially search for WM_COMMAND.
Those EN_... definitions will be stored in wmEvent, so check wmEvent for EN_SETFOCUS.
Last edited on
Thanks for the help :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
case WM_COMMAND:
	wmId    = LOWORD(wParam);
	wmEvent = HIWORD(wParam);
	// Parse the menu selections:
	switch (wmId)
	{
	case IDS_EDIT01:
		switch (wmEvent)
		{
		case EN_SETFOCUS:
			MessageBox(NULL, NULL, NULL, NULL);
			break;
		}
		break;

//Blah 


This works. Hmm, perhaps when I click on the box it makes two messages.
I don't know... I always used to hate EditBox's Message system with WM_COMMAND.
Topic archived. No new replies allowed.