PC Review


Reply
Thread Tools Rate Thread

Add an image to a commandbar button

 
 
Marc
Guest
Posts: n/a
 
      27th Nov 2003
I'm trying to add an image to a commandbar button. I was using
objButton.Picture to load .BMPs onto the buttons. This works great in
Outlook 2002 and 2003 but the Outlook 2000 model doesn't support this. I
know you can use the copyface and pasteface methods to copy an image from
another button but how do you do this if you don't currently have a
commandbar button with the image you want to use?
Using the Outlook 2000 model is there a way to adding a image to a button
from an imagelist or from a button on a form in the add-in ... or any other
way?

Thanks,
Marc


 
Reply With Quote
 
 
 
 
Dmitry Streblechenko
Guest
Posts: n/a
 
      27th Nov 2003
You don't need to call CopyFace on an existing button - copy your own bitmap
to the clipboard, then call PasteFace.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Marc" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm trying to add an image to a commandbar button. I was using
> objButton.Picture to load .BMPs onto the buttons. This works great in
> Outlook 2002 and 2003 but the Outlook 2000 model doesn't support this. I
> know you can use the copyface and pasteface methods to copy an image from
> another button but how do you do this if you don't currently have a
> commandbar button with the image you want to use?
> Using the Outlook 2000 model is there a way to adding a image to a button
> from an imagelist or from a button on a form in the add-in ... or any

other
> way?
>
> Thanks,
> Marc
>
>



 
Reply With Quote
 
Marc
Guest
Posts: n/a
 
      27th Nov 2003
Thanks Dmitry ... I did some playing around last night and figure it out. I
just created a new form in my add-in that contains all of my images and now
I can do the following

Private Sub AddMyCommandBar(objCBs As CommandBars)
Dim objCB As CommandBar
Dim objCBCs As CommandBarControls, objCBC As CommandBarControl

On Error Resume Next

Set objCB = objCBs.Add("MyCommandBar", msoBarTop, , True)
Set objCBCs = objCB.Controls

Set btnOptions = objCBCs.Add(, , , , True)
btnOptions.Caption = "Mailfuse Options"
btnOptions.OnAction = "!<" & msProgID & ">"
btnOptions.Style = msoButtonIconAndCaption
Clipboard.SetData frmImages.imgOptions.Picture, vbCFBitmap
btnOptions.PasteFace
...

Maybe you/someone can answer another question while looking at this code. I
use the above code to add a new commandbar and buttons to the inspector when
a mail item is viewed. I've tested this on a few different OSs and also
different versions of Outlook and things work pretty good. In Outlook 2003
however each time an email is opened it adds the commandbar but the old one
is still there. In Outlook 2000 and 2002 the old commandbar seems to be
removed after the inspector is closed so I don't get duplicates.

How can I check when the inspector opens to see if the commandbar is still
there so I can skip trying to readd it? I tried doing something like
objCBs.FindControl to see if I can find one of my controls but I dont' know
what to put as the ID to search for.
Should I make objCB global istead of creating in the sub so I can check
reference it my moInspectors_NewInspector event?

I know I should realy start a new thread for this question so if I don't get
any responses I'll create a new post.

Thanks,
Marc

"Dmitry Streblechenko" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> You don't need to call CopyFace on an existing button - copy your own

bitmap
> to the clipboard, then call PasteFace.
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
>
> "Marc" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I'm trying to add an image to a commandbar button. I was using
> > objButton.Picture to load .BMPs onto the buttons. This works great in
> > Outlook 2002 and 2003 but the Outlook 2000 model doesn't support this. I
> > know you can use the copyface and pasteface methods to copy an image

from
> > another button but how do you do this if you don't currently have a
> > commandbar button with the image you want to use?
> > Using the Outlook 2000 model is there a way to adding a image to a

button
> > from an imagelist or from a button on a form in the add-in ... or any

> other
> > way?
> >
> > Thanks,
> > Marc
> >
> >

>
>



 
Reply With Quote
 
Dmitry Streblechenko
Guest
Posts: n/a
 
      27th Nov 2003
This is normal: Outlook reuses inspectors, which results in the old custom
toolbars to be there but not hooked up to your event handlers.
Use Inspector.CommandBars.Item("YourToolbarName") to try to access an
existing toolbar. If you don't get an error, simply delete that toolbar,
then add the toolbar again whether it was there before or not.
Also make sure you set the Temporary parameter to true when calling
CommandBars.Add() to make sure your roolbar is not persisted between Outlook
sessions.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Marc" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks Dmitry ... I did some playing around last night and figure it out.

I
> just created a new form in my add-in that contains all of my images and

now
> I can do the following
>
> Private Sub AddMyCommandBar(objCBs As CommandBars)
> Dim objCB As CommandBar
> Dim objCBCs As CommandBarControls, objCBC As CommandBarControl
>
> On Error Resume Next
>
> Set objCB = objCBs.Add("MyCommandBar", msoBarTop, , True)
> Set objCBCs = objCB.Controls
>
> Set btnOptions = objCBCs.Add(, , , , True)
> btnOptions.Caption = "Mailfuse Options"
> btnOptions.OnAction = "!<" & msProgID & ">"
> btnOptions.Style = msoButtonIconAndCaption
> Clipboard.SetData frmImages.imgOptions.Picture, vbCFBitmap
> btnOptions.PasteFace
> ...
>
> Maybe you/someone can answer another question while looking at this code.

I
> use the above code to add a new commandbar and buttons to the inspector

when
> a mail item is viewed. I've tested this on a few different OSs and also
> different versions of Outlook and things work pretty good. In Outlook 2003
> however each time an email is opened it adds the commandbar but the old

one
> is still there. In Outlook 2000 and 2002 the old commandbar seems to be
> removed after the inspector is closed so I don't get duplicates.
>
> How can I check when the inspector opens to see if the commandbar is still
> there so I can skip trying to readd it? I tried doing something like
> objCBs.FindControl to see if I can find one of my controls but I dont'

know
> what to put as the ID to search for.
> Should I make objCB global istead of creating in the sub so I can check
> reference it my moInspectors_NewInspector event?
>
> I know I should realy start a new thread for this question so if I don't

get
> any responses I'll create a new post.
>
> Thanks,
> Marc
>
> "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > You don't need to call CopyFace on an existing button - copy your own

> bitmap
> > to the clipboard, then call PasteFace.
> >
> > Dmitry Streblechenko (MVP)
> > http://www.dimastr.com/
> > OutlookSpy - Outlook, CDO
> > and MAPI Developer Tool
> >
> >
> > "Marc" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > I'm trying to add an image to a commandbar button. I was using
> > > objButton.Picture to load .BMPs onto the buttons. This works great in
> > > Outlook 2002 and 2003 but the Outlook 2000 model doesn't support this.

I
> > > know you can use the copyface and pasteface methods to copy an image

> from
> > > another button but how do you do this if you don't currently have a
> > > commandbar button with the image you want to use?
> > > Using the Outlook 2000 model is there a way to adding a image to a

> button
> > > from an imagelist or from a button on a form in the add-in ... or any

> > other
> > > way?
> > >
> > > Thanks,
> > > Marc
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Image added to CommandBar Buttons Andrew Microsoft Outlook Program Addins 2 26th Nov 2008 02:26 PM
CommandBar image remains in Clipboard after PasteFace LuisE Microsoft Excel Programming 0 6th Aug 2008 02:28 AM
Adding image to Outlook commandbar button saturn Microsoft Outlook Program Addins 3 3rd Aug 2007 02:13 PM
static commandbar Button =?Utf-8?B?SGFyaQ==?= Microsoft Excel Programming 0 22nd Jun 2004 10:50 AM
CommandBar button events Stee Microsoft Powerpoint 0 7th Jan 2004 12:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:48 PM.