Click here to Skip to main content
15,947,841 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Linked List Cleanup Pin
Greg Utas22-Mar-22 11:26
professionalGreg Utas22-Mar-22 11:26 
GeneralRe: Linked List Cleanup Pin
Calin Negru22-Mar-22 12:30
Calin Negru22-Mar-22 12:30 
GeneralRe: Linked List Cleanup Pin
Greg Utas24-Mar-22 7:19
professionalGreg Utas24-Mar-22 7:19 
GeneralRe: Linked List Cleanup Pin
Calin Negru24-Mar-22 6:04
Calin Negru24-Mar-22 6:04 
GeneralRe: Linked List Cleanup Pin
Greg Utas24-Mar-22 6:13
professionalGreg Utas24-Mar-22 6:13 
GeneralRe: Linked List Cleanup Pin
k505424-Mar-22 7:09
mvek505424-Mar-22 7:09 
GeneralRe: Linked List Cleanup Pin
Calin Negru24-Mar-22 21:12
Calin Negru24-Mar-22 21:12 
GeneralMFC MDI Change tab styles after Addview is completed via Property Sheet Pin
kittmaster21-Mar-22 10:55
kittmaster21-Mar-22 10:55 
I am using a property sheet for my app to adjust the options and GUI elements. When the file opens, the app has two tabs created via Addview and all of that is working. OnInitialUpdate sets the styles because it uses the registry settings when it starts. What I'm trying to do is have the styles adjust on an OnApply when the user selects the style they want. I have the OutputPane working correctly which is shown in the code below. What I can't get to work is to have the document tabs change on a Recalc/Redraw.
BOOL CSettingsUserTabs::OnApply()
{
    BOOL bResult = CMFCPropertyPage::OnApply();
    if (bResult)
    {
        // Update Output Pane Tab Styles (100% Working)
        AfxGetApp()->WriteProfileInt(_T("Settings"), _T("UserTabStyle"), m_style_tabs); // Save value to registry
        ((CMainFrame*)AfxGetMainWnd())->m_wndOutput.m_wndTabs.ModifyTabStyle((CMFCTabCtrl::Style)m_style_tabs);     
        ((CMainFrame*)AfxGetMainWnd())->m_wndOutput.m_wndTabs.RecalcLayout();

        // Update MDI tab styles (Not working)
        CMFCTabCtrl& MDI_STYLES = ((CMainFrame*)AfxGetMainWnd())->GetMDITabs();
        MDI_STYLES.ModifyTabStyle((CMFCTabCtrl::Style)m_style_tabs);
        MDI_STYLES.RecalcLayout();
        CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWndEx, GetTopLevelFrame());
            pMainFrame->SetFocus();
            pMainFrame->RecalcLayout();
    }
    return bResult;
}

Any ideas what I can do solve this problem? I've scoured the net for examples on how to solve this issue and yet to get it to work. There is a TabControl solution in the Microsoft master repository to show how it works, but since I'm using a propertysheet to control it, the example does work but the example doesn't use the AddView so I can't use it as a good example.

Here is the code that loads the RUNTIME_CLASSES where the tabs are created:
void CMovieView::OnInitialUpdate()
{

    // add views to program     
    AddView(RUNTIME_CLASS(CTabView1), AfxStringID(IDS_TAB1));
    AddView(RUNTIME_CLASS(CTabView2), AfxStringID(IDS_TAB2));

    GetTabControl().EnableTabSwap(TRUE);
    GetTabControl().SetLocation(CMFCBaseTabCtrl::Location::LOCATION_TOP);
    GetTabControl().EnableAutoColor(TRUE);

    // Modify User Define tab style:
    int UserTabStyle = AfxGetApp()->GetProfileInt(_T("Settings"), _T("UserTabStyle"), 0); //Get value from registry

    // If the key doesn't exist, UserTableStyle will be 0 or FALSE;
    if (UserTabStyle != FALSE && UserTabStyle <= 8) { // User selected tab style type

        int EnumUserTabStyle = UserTabStyle - 1; // Fix enum if key doesn't exist.
        GetTabControl().ModifyTabStyle(static_cast<CMFCTabCtrl::Style>(EnumUserTabStyle));

    }
    else { // Default tabs style if Reg key does not exist i.e. new install/program reset

        GetTabControl().ModifyTabStyle(CMFCTabCtrl::STYLE_FLAT);
    }

    CTabView::OnInitialUpdate();

}

This works on creation, I can't get it to work when the OnApply() is used because you can't recall OnInitialUpdate for something already created. I can't seem to get GetTabControl() to work after on create as a separate function....so I'm unclear on how to solve this problem. Does anyone have any ideas on how I can modify my code to get it working?

Thanks,
Chris
QuestionMessage Closed Pin
21-Mar-22 10:28
Member 1496877121-Mar-22 10:28 
AnswerRe: how do I verify - "all the ducks in the row "? Pin
k505421-Mar-22 11:09
mvek505421-Mar-22 11:09 
GeneralMessage Closed Pin
21-Mar-22 15:28
Member 1496877121-Mar-22 15:28 
GeneralRe: how do I verify - "all the ducks in the row "? Pin
Richard MacCutchan21-Mar-22 22:38
mveRichard MacCutchan21-Mar-22 22:38 
GeneralMessage Closed Pin
24-Mar-22 10:36
Member 1496877124-Mar-22 10:36 
GeneralRe: how do I verify - "all the ducks in the row "? Pin
k505424-Mar-22 11:06
mvek505424-Mar-22 11:06 
GeneralMessage Closed Pin
24-Mar-22 13:25
Member 1496877124-Mar-22 13:25 
GeneralRe: how do I verify - "all the ducks in the row "? Pin
Richard MacCutchan24-Mar-22 21:49
mveRichard MacCutchan24-Mar-22 21:49 
GeneralMessage Closed Pin
25-Mar-22 10:17
Member 1496877125-Mar-22 10:17 
GeneralRe: how do I verify - "all the ducks in the row "? Pin
k505425-Mar-22 11:26
mvek505425-Mar-22 11:26 
GeneralMessage Closed Pin
25-Mar-22 14:25
Member 1496877125-Mar-22 14:25 
GeneralMessage Closed Pin
25-Mar-22 16:33
Member 1496877125-Mar-22 16:33 
GeneralRe: how do I verify - "all the ducks in the row "? Pin
k505428-Mar-22 5:26
mvek505428-Mar-22 5:26 
GeneralRe: how do I verify - "all the ducks in the row "? Pin
Richard MacCutchan25-Mar-22 22:53
mveRichard MacCutchan25-Mar-22 22:53 
GeneralRe: how do I verify - "all the ducks in the row "? Pin
trønderen25-Mar-22 12:58
trønderen25-Mar-22 12:58 
GeneralRe: how do I verify - "all the ducks in the row "? Pin
k505426-Mar-22 5:07
mvek505426-Mar-22 5:07 
GeneralRe: how do I verify - "all the ducks in the row "? Pin
Richard MacCutchan25-Mar-22 22:51
mveRichard MacCutchan25-Mar-22 22:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.