Creating Office::_CommandBarButton with custom image

  • Thread starter Antonio Casilias
  • Start date
A

Antonio Casilias

Hi

I'm trying to create CommandBarButton at toolbar.
I need a button with width = 80 and with 80x20 image on it; without captions.
But the button I've got has 16x16 squeezed image.

Here is my code:

CComQIPtr<Office::_CommandBarButton> spCmdButton(spNewBar);
ATLASSERT(spCmdButton);

//! Loading bitmap
HBITMAP hBmp =(HBITMAP)::LoadImage(_AtlModule.hInstance,
MAKEINTRESOURCE(faceId),IMAGE_BITMAP,80,20, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT );

// put bitmap into Clipboard
::OpenClipboard(NULL);
::EmptyClipboard();
::SetClipboardData(CF_BITMAP, (HANDLE)hBmp);
::CloseClipboard();
::DeleteObject(hBmp);

spCmdButton->put_Width(80);
spCmdButton->put_Visible(VARIANT_TRUE);
spCmdButton->put_Caption(caption);
spCmdButton->put_Enabled(VARIANT_TRUE);
spCmdButton->put_TooltipText(tooltip);
spCmdButton->put_Tag(tag);
spCmdButton->put_Style(Office::msoButtonIcon);

//! Pasting bitmap
spCmdButton->PasteFace();
spNewCmdBar->put_Visible(VARIANT_TRUE);

Please, advice me to create my custom sized image.
 
B

Bubu

Hi Antonio.
I tried to do the same thing, but it was unsuccessfull. I believe the
commandbar buttons support on ly 16X16 images.
Maybe you have an idea how to handle builtin (from standard
commandbars) button clicks? Ive postd question about this :


I'm developing Office COM addin for Word, PP, and Excel. I use
C++/ATL 7 and _IDTExtensibility2 stuff. My problem is how to handle
click events from built in buttons and commandbars , for example I
would like to handle click from "Document Map" button on Standard
command bar. I thought that there is CommandBar onlcick event - alas
there is no one. I have no problem to handle events from my own-created

buttons. I use IDispEventSimpleImpl<id ,CConnect
,&__uuidof(Office::_CommandBar­ButtonEvents) and
SINK_ENTRY_INFO and
CommandButtonXXXXeEvents::Disp­EventAdvise((IDispatch*)myButt­on)
and define my own event handler function. I tried get specific built
in button and subscribe to its event source in same manner
CommandButtonXXXXeEvents::Disp­EventAdvise , however I get
E_NOINTERFACE error.
May be somebody knows how to handle click from Line color dialog - this

nice popup dialog form Drawing commandbar? There is a color palette
there with small colored rectangles.
There is nothing in MSDN about this problem. Any input or/and ideas
will be highly appreciated.
Best regards David.
 
C

Cindy M -WordMVP-

Hi Antonio,

Office toolbar buttons are limited to a 16x16 raster; there's nothing you can do to
change that.
I'm trying to create CommandBarButton at toolbar.
I need a button with width = 80 and with 80x20 image on it; without captions.
But the button I've got has 16x16 squeezed image.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in the
newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top