Professional UI Solutions
Site Map   /  Register


Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Populate CExtToolControlBar Collapse All
Subject Author Date
Bart Kampers Sep 16, 2008 - 9:33 AM

Hello there,


I created a CExtToolControlBar and populated it by InsertButton(). Now the buttons are invisible so I want to assign bitmaps from the resource to them. How do I have to do that? Please, can anybody give an example?


Thanks in advance.



Technical Support Sep 23, 2008 - 5:48 AM

We are sorry for the delay with this reply. The CExtCmdManager::CmdAllocPtr() method allocates specified command identifier and returns command item pointer. If the command identifier is already allocated, then the method simply returns NULL(). We guess you have invoked it twice or more times for the same command identifier. You should check whether command is already allocated using the CExtCmdManager::CmdGetPtr() method and only then allocate it. You can also request zero command identifier allocation in the CExtCmdManager::CmdAllocPtr() method. In this case it will automatically generate new unique non-zero command identifier and allocate command item for it. Thank you for your documentation related comment.

Bart Kampers Sep 25, 2008 - 6:43 AM

It is still not clear to me how I can set the button text. CmdGetPtr does return a pointer but now what? Again the documentation does not give any clue at all.

And further, when I don’t set an incon to the command CmdGetPtr still returns NULL. So how can I make a button without an icon but with a text?

Technical Support Sep 26, 2008 - 12:26 PM

The returned CExtCmdItem pointer is what you should use. The CExtCmdItem::m_sToolbarText property is command text in toolbar. If the returned CExtCmdItem pointer is NULL, then the command is not registered in the command manager and not present in toolbar.

Technical Support Sep 17, 2008 - 5:59 AM

The toolbar buttons do not contain any bitmaps. You should register commands in the command manager for all the inserted toolbar buttons. This can be done using the g_CmdManager->CmdAllocPtr(...) code. The method returns a pointer to the CExtCmdItem object which contains all the text properties of command. You can assign text for toolbar button, tooltip text and status tip text. The command icons are also stored in the command manager. You can assign icon to command using one of the overloaded CExtCmdManager::CmdSetIcon() methods.

Bart Kampers Sep 18, 2008 - 4:44 AM

Thanks for your response.

I impelentend my buttons like in the method below and this works OK. But I still have some questions:

* The method g_CmdManager->CmdAllocPtr always returns NULL. When I give NULL for the first parameter it retrurns "something" but I cannot figure out how to assign texts.

* The bUseCmdIconObject parameter in g_CmdManager->CmdSetIcon seems to work opposite to the documentation, which says: "If true, a copy of the object specified by pCmdIcon is created; otherwise, the icon object pointed to by pCmdIcon is used."

void CMainFrame::CreateButton(CExtToolControlBar& bar, UINT nCmdID, UINT nIDResource)
bar.InsertButton(-1, nCmdID);
//__EXT_MFC_SAFE_LPCTSTR profileName = g_CmdManager->ProfileNameFromWnd(this->GetSafeHwnd());
__EXT_MFC_SAFE_LPCTSTR profileName = ::AfxGetApp()->m_pszProfileName;
//__EXT_MFC_SAFE_LPCTSTR profileName = NULL;

CBitmap bitmap;

CExtCmdIcon icon;// = new CExtCmdIcon;
icon.AssignFromHBITMAP(bitmap, RGB(255, 0, 255));
g_CmdManager->CmdSetIcon(profileName, nCmdID, &icon, false);

CExtCmdItem* item = g_CmdManager->CmdAllocPtr(profileName, nCmdID);
//item->m_sAccelText = "m_sAccelText";
//item->m_sMenuText = "m_sMenuText";
//item->m_sToolbarText = "m_sToolbarText";
//item->m_sMenuText = "m_sMenuText";