Jump to content
  • Advertisement
Sign in to follow this  
AndyGeers

More Windows dialog weirdness

This topic is 4481 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've made a bit of progress on my attempt to try and get a tabbed control working on my dialog created using the Windows API, but now I've got a new problem. Basically, the situation is as follows: 1) I call InitCommonControlsEx to enable the use of the tab control 2) I create the parent dialog from a resource using the CreateDialog function. This dialog contains a tab control. 3) I create two child dialogs, also using resources and CreateDialog, and use their window handles to add two tabs to the parent dialog. 4) When the parent dialog receives WM_NOTIFY messages I switch tabs by hiding the old tab dialog and showing the new one. The weird part is this: a) I have some radio buttons (that look like normal command buttons) on one of the tabs, and they work perfectly, getting WM_COMMAND messages each time they're pressed and so on. b) I have a normal command button on the SAME tab, and when you click on that the whole thing just locks up and dies. The last messages received are WM_MOUSEACTIVATE and then two WM_SETCURSORs. The (shared) DialogProc for the parent and the tabs is as follows:
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_INITDIALOG:
        {
            // Do nothing
            return TRUE;
        }

        case WM_CLOSE:
        {			
            // Check if it's the main dialog or one of the tabs
            if (hWnd == CEditor::Get()->GetHwnd())
            {
                // Disable editor
                CEditor::Get()->Deactivate();		
            }
            return TRUE;		
        }		

        case WM_NOTIFY:
        {
            LPNMHDR pnmh = (LPNMHDR) lParam;
            switch (pnmh->code)
            {
                case TCN_SELCHANGE:
                {
                    // Select the current tab
                    CEditor::Get()->SelectTab();
                    return TRUE;
                };
            }
            break;
        }		

        case WM_COMMAND:
        {			
            switch (LOWORD(wParam))
            {
                case IDC_AREA_CUSTOM:
                case IDC_AREA_SUBSETS:
                case IDC_AREA_TRIS:
                {
                    // (The radio buttons)
                    // Process this message    
                    CEditor::Get()->ModifyArea(LOWORD(wParam));
                    return TRUE;
                }

                case IDC_NEWAREA:
	        {
                    // (The command button)
                    // Create new area
                    CEditor::Get()->NewArea();
                    return TRUE;
                }
            };
            break;
	}

	// Call default processor
	return FALSE;
}

void CEditor::SelectTab()
{
	// Get handle to tabs control
	HWND hTabs = GetDlgItem(m_hDialog, IDC_TAB1);

	// See how many tabs there are, and which is selected
	int nTabCount = TabCtrl_GetItemCount(hTabs);
	int nSelectedTab = TabCtrl_GetCurSel(hTabs);

	// Loop over each tab in turn
	for (int nTab = 0; nTab < nTabCount; nTab ++)
	{
		// Get tab details
		TC_ITEM tiTab;
		tiTab.mask = TCIF_PARAM;		
		TabCtrl_GetItem(hTabs, nTab, &tiTab);

		if (tiTab.lParam)
		{
			if (nTab == nSelectedTab)
			{
				// Show this tab
				ShowWindow((HWND)tiTab.lParam, SW_SHOW);			
			}
			else
			{
				// Hide this tab
				ShowWindow((HWND)tiTab.lParam, SW_HIDE);
			}
		}
	}
}

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!