Skip to main content
gamedev.net
🔒 Locked

Unresponsive Edit Box

Started by doctorsixstring May 12, 2003 at 4:43 PM 5 replies 350+ views
Original Post
doctorsixstring
doctorsixstring
I have a window (hwnd_main) that has a modeless child dialog box (hwnd_child). ''hwnd_child'' is a popup dialog box with a few edit boxes on it. While I am able to click on any of the edit boxes in hwnd_child, I can''t edit them with the keyboard (but I can copy/paste text into them). This has me baffled. I have tried everything I can think of. I have changed every seemingly-relevent flag, I have tried explicitly using SetFocus() to the set the keyboard focus to these edit boxes, etc. Here are some random tidbits that may be helpful to determine the problem: - When the WM_INITDIALOG is processed for hwnd_child, I set the focus to hwnd_main. - Running the following code produces a massive amount of messageboxes, but suddenly allows me to type text into the edit boxes in hwnd_child. Excerpt from hwnd_child DlgProc():
  
case WM_MOUSEMOVE:
{
	HWND hCurFocusWnd = GetFocus();

	if(hCurFocusWnd == hwnd_child)
		MessageBox(0,"hwnd_child has focus",0,0);
	else
		MessageBox(0,"hwnd_child doesn''t have focus",0,0);

	return 0;
}
  
- Here is my message pump code:
  
MSG msg;

//as long as m_bShutdown==false, the program will run through this loop

while(!m_bShutdown)
{
	if( GetMessage( &msg, NULL, 0, 0 ) )
		if(!IsDialogMessage(msg.hwnd, &msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
}
  
I know that this bug has something to do with which window/control has the current keyboard focus, but I can''t seem to figure out a solution. Any thoughts? -Mike
doctorsixstring
doctorsixstring
Any thoughts? If I need to post additional data, feel free to let me know. I plan on spending the next 8 or 9 hours working on this problem, so any help would be very appreciated.

Thanks,

Mike
doctorsixstring
doctorsixstring
I can''t be the only person who has ever experienced this problem. I will gladly provide additional information if any one asks. I would love to hear any suggestions/guesses.

-Mike
doctorsixstring
doctorsixstring
quote:
Original post by Anonymous Poster
mouse move will get called so many times... dont put message boxes in it.


Agreed. I have found that it is difficult to debug bugs related to window activation/visibility/focus/etc., because message boxes are useless (the message box instantly transfers focus to itself and deactivates the currently-active window).

The one redeeming (?) factor of the message boxes in the WM_MOUSEMOVE sequence is that, for some reason, I can eventually enter text into the misbehaving edit boxes. Dozens of message boxes appear as I move the mouse around the modeless dialog (obviously), but eventually my edit boxes work. I have been trying to figure out why, but to no avail.

Before I left work this afternoon, I had the dialog''s message handling procedure output the message code of every message processed by the dialog. When I return to work in the morning, I am going to go over this and see if anything looks funny.

In the meantime, I would love to hear any other thoughts or comments.

-Mike
doctorsixstring
doctorsixstring
This problem is really starting to bother me. I have begun a second application at home (a game editor) that is uses a dialog box as a child of the main window. It too is not allowing me to edit the values in the edit boxes.

I am baffled as to what is going on - I have never had this problem before this week.

Any thoughts?

-Mike
doctorsixstring
doctorsixstring
Well it looks like I may have finally found the problem. I was using the following code for my message pump:


  
MSG msg;

while(!g_bShutdown)
{
if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
if(!IsDialogMessage(msg.hwnd, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}


My error was passing the msg.hwnd handle to IsDialogMessage(...). I''m not sure why I was doing this, but I replaced it with the handle to my specific child dialog box. I suppose that an individual IsDialogMessage() call is needed for each dialog box that exists.

-Mike

Topic Locked

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

Sign in to reply to this topic.