Print Page | Close Window

Quick Access Buttons Inactive

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=5464
Printed Date: 11 November 2025 at 4:48pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Quick Access Buttons Inactive
Posted By: Tsenoh
Subject: Quick Access Buttons Inactive
Date Posted: 08 November 2006 at 12:17pm
Hi!

I am rather new to XTP and having difficulties with some elements.

I am trying to implement Ribbon Toolbar in a dialog in my application. Problem is with Quick Access. I managed to add buttons like in the sample application, but the buttons are inactive (no animation, and no command is sent when clicked). The ID's used for buttons are taken from IDR_MAINFRAME menu.

What do I have to have in mind when implementing Ribbon in an Child-Dialog?

Are there any tutorials on using XTP Controlls?

Thanks!

Bojan Hrnkas



Replies:
Posted By: Oleg
Date Posted: 08 November 2006 at 2:33pm
Hello,
 
Add to message map
 ON_MESSAGE(WM_KICKIDLE, OnKickIdle)
 
and method
 
LRESULT CDialogSampleDlg::OnKickIdle(WPARAM, LPARAM)
{
 GetCommandBars()->UpdateCommandBars();
  return 0;
}
 
now add all command handlers for command you need to message map.
 
See DialogSample project.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Tsenoh
Date Posted: 09 November 2006 at 9:15am
Thanks for the fast answer!

However, the problem still persists. The function OnKickIdle() is called only if Ribbon is not created.
The thing is, I have only one class called FlexibleDlg, that is used for all dialogs in my application. Sometimes it schould have Ribbon Toolbar, sometimes not.
I created the OnKickIdle() function like you suggested, and it is called only if I don't initialise Ribbon. I even had to put a check if ribbon is used or not, because when executing GetCommandBars()->UpdateCommandBars() on a dialog that has no toolbars, an exception is raised.
Why is OnKickIdle not called?
The only difference between a dialog with ribbon and the dialog without ribbon is following code:

//create ribbon if needed
if (m_bUseRibbon)
{
    if (!InitCommandBars())
        return -1;

    CXTPCommandBars* pCommandBars = GetCommandBars();

    pCommandBars->SetTheme(xtpThemeRibbon);

    pCommandBars->GetImageManager()->SetIcons(IDR_SMALLNAV);

    m_pRibbonBar = (CXTPRibbonBar*)pCommandBars->Add(_T("The Ribbon"), xtpBarTop, RUNTIME_CLASS(CXTPRibbonBar));

    if (!m_pRibbonBar)
    {
        return FALSE;
    }

    m_pRibbonBar->EnableDocking(0);
    m_pRibbonBar->GetTabPaintManager()->m_bSelectOnButtonDown = FALSE;

    CMenu menu;
    menu.CreateMenu();
    menu.AppendMenu(MF_STRING, 1, "Fuktion 1");
    menu.AppendMenu(MF_STRING, 2, "Fuktion 2");
    CXTPControlPopup* pControlFile = (CXTPControlPopup*)m_pRibbonBar->AddSystemButton(0);
    pControlFile->SetCommandBar(&menu);

    CreateRibbonElements();
    //CXTPRibbonTab* pTabHome = m_pRibbonBar->AddTab("Home (Test)");

    m_pRibbonBar->GetQuickAccessControls()->CreateOriginalControls();
    m_pRibbonBar->ShowQuickAccess(TRUE);

    m_pRibbonBar->SetCloseable(FALSE);

    m_pRibbonBar->EnableFrameTheme();

    m_bRibbonCreated = TRUE;
}


What do I do wrong?

Thanks!


Posted By: Tsenoh
Date Posted: 09 November 2006 at 9:37am
P.S.

I create QuickAccess buttons like this:

m_pRibbonBar->GetQuickAccessControls()->Add(xtpControlButton, (UINT)pElement->dParameter1);


Posted By: Tsenoh
Date Posted: 09 November 2006 at 10:28am
I "kind of" solved the problem. Initially, I didn't have a message handler for the buttons ( OnNavFirst() ). Instead of that I had a single message handler "OnCommand" that was supposed to capture all commands and send coresponding message to the parent. I have to make it that way, because I will always have dynamically created controlls.
When I created a message handler for a single button in QuickAccessControls, all buttons were enabled, even those that have no message handler.
I intend to leave a dummy message handler as a workaround. Is there a possibility to solve this in a more elegant way?

Thanks!

Bojan Hrnkas



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net