MFC MDI Property Page Radio buttons work on one page for function 1, buttons on another page for function 2 don't fire

186 views Asked by At

Continuing my dialog settings Property Sheet/Page dialog, I have 4 out of 5 pages working. In MFC they offer the neat style method called ApplicationLook, on one of my property pages, I have the radio buttons all set to the values of the case value in that function and it works as expected. I have replicated the switch function of ApplicationLook and changed values for my other property page which will control the tabs styles that is offered. The property page that has the tabs follow the enum of the tabs styles that are offered.

Using the ON_COMMAND_RANGE just as ApplicationLook does, the radio buttons should be entering the tabs function....but it never does...like no one is home. However, I have created two MenuItems for testing called tab1 and tab2 which have the same case identifier and both of those work and enter the tabs function. The radio buttons of the property sheet have the same case identifier but it never fires the function. I've looked to see if the ApplicationLook has any DDX or DDV controls anywhere and I got lucky on the ApplicationLook but there are none, so that doesn't seem to be the issue.

For the sake of testing, the only thing that should happen on the function entry is write a test string to the output window showing it entered that case and then write the registry setting value...basically a skeleton function just to verify the radio button operation...which is why this question is being asked.

It is very strange since the menuitem and the radiobutton ID are the same, they should both trigger the function...but that doesn't happen. Since I copied the function elements verbatim, this has me stumped. Both functions live in MainFrame.cpp

BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWndEx)
    ON_COMMAND_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnApplicationLook)
    ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_WIN_2000, ID_VIEW_APPLOOK_WINDOWS_7, &CMainFrame::OnUpdateApplicationLook)
    
    ON_COMMAND_RANGE(STYLE_3D_USER, STYLE_3D_ROUNDED_SCROLL_USER, &CMainFrame::OnUserTabStyles)
    //ON_UPDATE_COMMAND_UI_RANGE(STYLE_3D_USER, STYLE_3D_ROUNDED_SCROLL_USER, &CMainFrame::OnUpdateApplicationLook)
END_MESSAGE_MAP()

Resource.h

#define STYLE_FLAT_USER                 201
#define STYLE_FLAT_SHARED_HORZ_SCROLL_USER 202
#define STYLE_3D_SCROLLED_USER          203
#define STYLE_3D_ONENOTE_USER           204
#define STYLE_3D_VS2005_USER            205
#define STYLE_3D_ROUNDED_USER           206
#define STYLE_3D_ROUNDED_SCROLL_USER    207
#define ID_VIEW_APPLOOK_WIN_2000        40013
#define ID_VIEW_APPLOOK_OFF_XP          40014
#define ID_VIEW_APPLOOK_WIN_XP          40015
#define ID_VIEW_APPLOOK_OFF_2003        40016
#define ID_VIEW_APPLOOK_VS_2005         40017
#define ID_VIEW_APPLOOK_VS_2008         40018
#define ID_VIEW_APPLOOK_OFF_2007_BLUE   40019
#define ID_VIEW_APPLOOK_OFF_2007_BLACK  40020
#define ID_VIEW_APPLOOK_OFF_2007_SILVER 40021
#define ID_VIEW_APPLOOK_OFF_2007_AQUA   40022
#define ID_VIEW_APPLOOK_WINDOWS_7       40023

I've truncated down the function to 2 cases and a default just for testing.

MainFrame.cpp

void CMainFrame::OnUserTabStyles(UINT id)
{
    CWaitCursor wait;
    m_nAppTabLook = id;

    switch (m_nAppTabLook)
    {
    case STYLE_3D_USER:
        AfxGetApp()->WriteProfileString(_T("Settings"), _T("UserTabStyle"), _T("STYLE_3D")); // Save value to registry
        m_wndOutput.AddStringStatusTab(_T("3D"));

        break;

    case STYLE_FLAT_SHARED_HORZ_SCROLL_USER:
        AfxGetApp()->WriteProfileString(_T("Settings"), _T("UserTabStyle"), _T("STYLE_FLAT_SHARED_HORZ_SCROLL")); // Save value to registry
        m_wndOutput.AddStringStatusTab(_T("H Scroll"));

        break;

    default:
        switch (m_nAppTabLook)
        {
        case STYLE_FLAT_USER:
            m_wndOutput.AddStringStatusTab(_T("Flat User"));

            break;
        }

    }

}

Settings Dialog Tab View

in the tabs dialog page, the 3d Style and Flat are set to the first two case values in the function set as:

STYLE_3D_USER
STYLE_FLAT_SHARED_HORZ_SCROLL_USER

As I mentioned above, the image below shows the two tabs that are set to the same case values of STYLE_3D_USER and STYLE_FLAT_SHARED_HORZ_SCROLL_USER to trigger the function as expected:

Tabs menus that do drive the function correctly

It does tell me (I think) that my message range map is working correctly. I just can't figure out why the radio button set to the exact ID value of the menuitem doesn't fire the function. As a note, I'm showing the exact same method I've used for ApplicationLook which is why I did the same for the tabbed view as I knew it worked one way...inspiring the tab view (which I can't get to work).

ApplicationLook doing it the same way, does work

I'm "almost" there if I can sort out why this isn't working. Any thoughts as to what could be wrong?

0

There are 0 answers