Print Page | Close Window

Command bar messages and bitmap

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=13813
Printed Date: 22 June 2025 at 11:24pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Command bar messages and bitmap
Posted By: JerryEvans
Subject: Command bar messages and bitmap
Date Posted: 25 March 2009 at 9:52pm
Hello.

2 questions for the panel:

1. In my frame class I assemble a command bar whic creates a drop-down menu:

// views
    CXTPToolBar* pToolBarViews = pCB->Add(_T("Views"), xtpBarTop);
    if (pToolBarViews)
    {
        // set up the bitmap
        pCB->GetImageManager()->SetIcons(IDR_TOOLBAR_VIEWS);
        //
        pToolBarViews->SetBarID(IDR_TOOLBAR_VIEWS);
       
        CXTPControlPopup* p = (CXTPControlPopup*)
        pToolBarViews->GetControls()->Add(xtpControlButtonPopup,ID_VIEW_SELECT);
        if (p)
        {
            p->SetStyle(xtpButtonCaption);
            p->SetCaption("Select Views");
            CMenu menu;
            menu.LoadMenu(IDR_SYSTEM);
            // we are only interested the View submenu
            p->SetCommandBar(menu.GetSubMenu(1));
        }
        pToolBarViews->GetControls()->Add(xtpControlButton,ID_VIEW_CONCISE);

How can I dynamically modify the menu?

I have mapped an event handler like this:

    ON_XTP_EXECUTE(ID_VIEW_SELECT,OnExecuteViewSelect)

with an implementation as below:

void CAppDoc::OnExecuteViewSelect(NMHDR* pNMHDR, LRESULT* pResult)
{
    NMXTPCONTROL* tagNMCONTROL = (NMXTPCONTROL*)pNMHDR;
    if (tagNMCONTROL)
    {
        CXTPControlPopup* pControl = (CXTPControlPopup*)tagNMCONTROL->pControl;
        if (pControl)
        {
            DBMSG(CMsg("OnExecuteViewSelect"));
        }
    }
}

but it is never called. The XTP_EXECUTE works fine for combo box controls on similiar toolbars.

I'd hope to get a pointer to a CMenu or similar and then add/delete/modify the menu items as appropriate in the context. So far nothing seems to work.

BTW The event handlers for each of the IDR_SYSTEM submenus are called  ...

2. Toolbar bitmaps - 2 toolbars created in the same manner behave differently. The problem is that a toolbar with a mixture of button and combo controls refuses to display the bitmaps for the final 2 controls created with:

pTBE->GetControls()->Add(xtpControlButton,ID_FINDER_MATCHCASE);

What I see is shown below (excuse the rubbish graphics - I've yet to work out why the bitmap is always rendered as 8bpp):



Here is a snap of the original in the VS2008 editor - both toolbars have 9 elements and are 16pixels wide by 15 pixels high ...



Any help greatly appreciated.

This all being performed with VS2008 SP1 running on XPSP3 using XTP 1202

Thx++

Jerry




Replies:
Posted By: Oleg
Date Posted: 26 March 2009 at 2:00am
Hi,
 
1. Catch WM_XTP_INITCOMMANDSPOPUP it called when Popup become visible.
 
2. I see you have 9 buttons on toolbar but 10 in bitmap.


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


Posted By: JerryEvans
Date Posted: 26 March 2009 at 7:24am
Oleg, thanks.

re the bitmap - the extra is that which VS always shows in its editor. There are 9 items defined in the toolbar. Why should the last two not display as bitmaps?

IDR_TOOLBAR_EDITOR TOOLBAR  16, 15
BEGIN
    BUTTON      ID_EDIT_SELECTALL
    BUTTON      ID_EDIT_UNDO
    BUTTON      ID_EDIT_REDO
    SEPARATOR
    BUTTON      ID_EDIT_FIND
    BUTTON      ID_FINDER_SEARCH
    SEPARATOR
    BUTTON      ID_EDIT_REPLACE
    BUTTON      ID_FINDER_REPLACE
    SEPARATOR
    BUTTON      ID_FINDER_MATCHCASE
    BUTTON      ID_FINDER_WHOLEWORD
END






Posted By: JerryEvans
Date Posted: 26 March 2009 at 10:47am
Oleg: In my CDocument derived class

    ON_XTP_INITCOMMANDSPOPUP(OnInitCommandsPopup)

Nothing is caught. I can see the notes in XTPCommandBarsDefines.h but this does not seem to work. Is there a message generated when a specific dropd-own menu is about to be displayed? OnInitCommandsPopup seems to be a little bit generic.


Posted By: Oleg
Date Posted: 27 March 2009 at 1:56am
Hi,
 
You have catch it it in CMainFrame.


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



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