Windows 10: dynamically switch ribbon resources in mfc application

Discus and support dynamically switch ribbon resources in mfc application in Windows 10 Customization to solve the problem; The user of my MFC app needs to be able to click on a ribbonbutton to switch to a different ribbon UI for example, in a differentlanguage. I have... Discussion in 'Windows 10 Customization' started by steveh01, Apr 21, 2021.

  1. steveh01 Win User

    dynamically switch ribbon resources in mfc application


    The user of my MFC app needs to be able to click on a ribbonbutton to switch to a different ribbon UI for example, in a differentlanguage. I have IDR_RIBBON and IDR_RIBBON1 in my project. The"switch" button has the following event handler:



    [COLOR=rgba0, 0, 255, 1]void[/COLOR][COLOR=rgba0, 0, 0, 1] [/COLOR][COLOR=rgba43, 145, 175, 1]CMainFrame[/COLOR][COLOR=rgba0, 0, 0, 1]::OnSwitchRibbon[/COLOR]

    [COLOR=rgba0, 0, 0, 1]{[/COLOR]

    [COLOR=rgba0, 0, 0, 1] [/COLOR][COLOR=rgba0, 128, 0, 1]// TODO:Add your command handler code here[/COLOR]

    [COLOR=rgba0, 0, 0, 1] m_wndRibbonBar.RemoveAllCategories;[/COLOR]

    [COLOR=rgba0, 0, 0, 1] m_wndRibbonBar.RemoveAllFromTabs;[/COLOR]

    [COLOR=rgba0, 0, 0, 1] m_wndRibbonBar.ShowPane0,0, 0;[/COLOR]

    [COLOR=rgba0, 0, 0, 1] [/COLOR][COLOR=rgba111, 0, 138, 1]VERIFY[/COLOR][COLOR=rgba0, 0, 0, 1]m_wndRibbonBar.LoadFromResource[/COLOR][COLOR=rgba111, 0, 138, 1]IDR_RIBBON1[/COLOR][COLOR=rgba0, 0, 0, 1];[/COLOR]
    [COLOR=rgba0, 0, 0, 1] m_wndRibbonBar.ShowPane1, 0, 0;[/COLOR]

    [COLOR=rgba0, 0, 0, 1] m_wndRibbonBar.RecalcLayout;[/COLOR]

    [COLOR=rgba0, 0, 0, 1] [/COLOR]

    [COLOR=rgba0, 0, 0, 1] RecalcLayout;[/COLOR]

    [COLOR=rgba0, 0, 0, 1] RedrawWindow;[/COLOR]


    [COLOR=rgba0, 0, 0, 1]}[/COLOR]



    As written, it causes an Access Violation in the followingMFC ribbon panel code at the RedrawElement function below:


    void CMFCRibbonPanel::MouseButtonUpCPoint point

    {

    ASSERT_VALIDthis;

    m_bMouseIsDown= FALSE;

    ifm_pHighlighted != NULL

    {

    ASSERT_VALIDm_pHighlighted;

    HWNDhwndParent = GetParentWnd->GetSafeHwnd;
    CMFCRibbonBaseElement*pHighlighted = m_pHighlighted;
    m_pHighlighted->OnLButtonUppoint;
    if::IsWindowhwndParent && pHighlighted->m_bIsPressed

    {

    pHighlighted->m_bIsPressed= FALSE;

    [COLOR=rgba255, 0, 0, 1] RedrawElementpHighlighted; ACCESS VIOLATION[/COLOR]



    If the following 2 lines are added before the call toLoadResourceIDR_RIBBON1 in my code:


    [COLOR=rgba0, 0, 0, 1] [/COLOR][COLOR=rgba0, 128, 0, 1]RemovePaneFromDockManager&m_wndRibbonBar,TRUE, TRUE, FALSE, NULL;[/COLOR]

    [COLOR=rgba0, 0, 0, 1] [/COLOR][COLOR=rgba0, 128, 0, 1]VERIFYm_wndRibbonBar.Createthis;[/COLOR]

    [COLOR=rgba0, 128, 0, 1][/COLOR]
    [COLOR=rgba0, 0, 0, 1]Then itruns without the access violation. But then I have to move all other bars inthe app like a caption bar to get the original docking pane layout. Is thereany way around this?[/COLOR]


    [COLOR=rgba0, 0, 0, 1]Finally, there is another bugin the CMFC ribbon code that causes Print Preview in the new ribbonIDR_RIBBON1 to fail. How can that be avoided?[/COLOR]


    [COLOR=rgba0, 128, 0, 1]
    [/COLOR]

    :)
     
    steveh01, Apr 21, 2021
    #1
  2. HUSKIE Win User

    avcapture mfc application has stopped working

    hi i had a big problem with my tv dongle when i was watching after that tv has stopping and has an error that avcapture mfc application has stopped? just wondering i been totally installed those applications and driver as well but still has error..... currently running win xp with 32 bit
     
    HUSKIE, Apr 21, 2021
    #2
  3. KeatKean Win User
    KeatKean, Apr 21, 2021
    #3
  4. Brink Win User

    dynamically switch ribbon resources in mfc application

    Simplified Ribbon is now available in Excel for the web

    Source: https://techcommunity.microsoft.com/...b/ba-p/1995215
     
    Brink, Apr 21, 2021
    #4
Thema:

dynamically switch ribbon resources in mfc application

Loading...
  1. dynamically switch ribbon resources in mfc application - Similar Threads - dynamically switch ribbon

  2. Missing application ribbons

    in Windows 10 Software and Apps
    Missing application ribbons: We are a team of 12 people running Office 365. In the office we are connected to a server but also have remote access through a RDP connection. One of the users has issues with the application header/ribbon disappearing and this happens both in the office on her desktop PC...
  3. Missing application ribbons

    in Windows 10 BSOD Crashes and Debugging
    Missing application ribbons: We are a team of 12 people running Office 365. In the office we are connected to a server but also have remote access through a RDP connection. One of the users has issues with the application header/ribbon disappearing and this happens both in the office on her desktop PC...
  4. Missing application ribbons

    in Windows 10 Gaming
    Missing application ribbons: We are a team of 12 people running Office 365. In the office we are connected to a server but also have remote access through a RDP connection. One of the users has issues with the application header/ribbon disappearing and this happens both in the office on her desktop PC...
  5. AMD and NVIDIA dynamic switch mouse freeze

    in Windows 10 Drivers and Hardware
    AMD and NVIDIA dynamic switch mouse freeze: I Got new legion 5 2021 model with r7 5800h and RTX 3070 I'm facing an annoying problem, I investigated it and found it was there about three years old Laptop Freeze Problem but not worked for meLaptop mouse freezes for a fraction of time in these cases and me be more, but...
  6. Does anyone know where to find Dark mode ribbon resources ??

    in Windows 10 Ask Insider
    Does anyone know where to find Dark mode ribbon resources ??: Does anyone has idea where can I find those ? I looked into UiRibbonres.dll and all i see is some green/yellow and black bitmaps which I'm assuming are somehow rendering the light theme. I want to make it grey. Thanks. submitted by /u/wealstarrr [link] [comments]...
  7. Dynamic HDR Switching?

    in Windows 10 Ask Insider
    Dynamic HDR Switching?: Running Windows 10 (1909) with a Nvidia 2080Ti on a Samsung CRG9. Some games (for example, Destiny 2) will automatically switch to HDR when launched, even if the HDR option isn't turned on in Windows. Most games, though (for example, Sea of Thieves and Modern Warfare) won't....
  8. Dynamic disks not showing in Resource Monitor

    in Windows 10 Ask Insider
    Dynamic disks not showing in Resource Monitor: [ATTACH] Not sure why this happens... Hopefully someone can help me solve this. This is the second system that it has occurred on for me. Back when I had a Win 7 Pro system with mirrored drives I distinctly remember both drives of a mirror showing in the resource monitor....
  9. Tops of applications missing Ribbons - see screenshot

    in Windows 10 Customization
    Tops of applications missing Ribbons - see screenshot: [ATTACH] I have a user who has this happen periodically. Usually closing the apps and re-opening them resolves this. So far this has happened in chrome, firefox, word, and Adobe reader. If closing/opening them doesnt work, we usually restart. the problem goes away for a...
  10. Recent Files in MFC application is not showing extensions

    in Windows 10 Customization
    Recent Files in MFC application is not showing extensions: Hello, I have an MFC application which has Recent Files option under File menu. If we hide the extensions in folder view, Recent Files in application also not showing extension even if the file name is stored with extension in the registry. How to display the extension...