Sign in to follow this  
AndyGeers

Windows dialog weirdness

Recommended Posts

Hmm, getting really frustrated by some weird behaviour with my windows API stuff that really shouldn't be the focus of my development time but is driving me nuts... any help much appreciated. I created a Dialog resource using MSVC, and get a HWND using CreateDialog and up to this point all is fine. Then I decided that I wanted a tabbed control on my dialog, and it didn't seem like Windows supports automatic hiding and showing of the controls on each tab page (VB style) so the easiest way seemed to be create additional child Dialogs with CreateDialog and hiding and showing them as necessary. Anyway, I now get really weird behaviour. If you just play with the controls in the parent Dialog all is fine, they work as expected and you can close the parent Dialog nicely. If, however, you interact with the controls of the child dialog, then the whole thing seems to lock up when you try to close the parent dialog -- it gets the WM_CLOSE message, which calls ShowWindow(hParent, SW_HIDE); a WM_SHOW message is then received, but the dialog doesn't get hidden and the whole application freezes. If I change the mechanism to use DestroyWindow on WM_CLOSE rather than ShowWindow then it all works - so it's something to do with hiding the parent and child. Any thoughts? here's the shared message proc of the two dialogs (parent and child):
int CALLBACK CEditor::MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	if (uMsg <= 0x038F)
	{
		LOG_EVENT_L2_1(CLog::E_LOG_MISC, "Editor received windows message (%s)", NDebug::g_szMessageName[uMsg]);
	}
	else if (uMsg == 0x0400)
	{
		LOG_EVENT_L2_0(CLog::E_LOG_MISC, "Editor received windows message (WM_USER)");
	}

	switch (uMsg) 
	{ 
		case WM_CLOSE:
		{			
			// Hide the parent window
			ShowWindow(CEditor::Get()->GetHwnd(), SW_HIDE);
			return TRUE;		
		}

		case WM_COMMAND:
		{			
			switch (LOWORD(wParam))
			{
				case IDC_AREA_CUSTOM:
				case IDC_AREA_SUBSETS:
				case IDC_AREA_TRIS:
				{
					// Process this message
					...
					return TRUE;
				}

				...
			}

			break;
		}		
	}
	
	return FALSE;
}






[Edited by - AndyGeers on March 11, 2006 10:10:32 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this