PC Review
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook Program Addins
Transparent Inspector images
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook Program Addins
Transparent Inspector images
![]() |
Transparent Inspector images |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
I am trying to add transparent images to CommandBarButtons in an
Inspector which of course doesn't use the mask property. I am using C#. Does anyone have any suggestions? Thanks |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Mask is supported for Outlook 2002 and later. It's only for Outlook 2000
that you need to use a workaround. Are you needing to support Outlook 2000? The trick with Outlook 2000 is to use one color as a mask color, say magenta. That color can only be used where you want masking. Then you do some fancy stuff with the Win32 API and separate the mask and image and pop them onto the clipboard and use PasteFace to add the button image. See http://www.daveswebsite.com/article...1/default.shtml for a C++ example and KB288771 for a VB example. Offhand I'm not familiar with any C# examples but there may be some out there if you Google for "PasteFace". -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Rog" <rog_21@yahoo.com> wrote in message news:uvJ6PLESGHA.1948@TK2MSFTNGP09.phx.gbl... >I am trying to add transparent images to CommandBarButtons in an Inspector >which of course doesn't use the mask property. I am using C#. > Does anyone have any suggestions? > Thanks |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Thanks Ken, so the mask is supported even on the inspector for Outlook
2003? I know it works for the Explorer buttons. Thanks Ken Slovak - [MVP - Outlook] wrote: > Mask is supported for Outlook 2002 and later. It's only for Outlook 2000 > that you need to use a workaround. Are you needing to support Outlook 2000? > > The trick with Outlook 2000 is to use one color as a mask color, say > magenta. That color can only be used where you want masking. Then you do > some fancy stuff with the Win32 API and separate the mask and image and > pop them onto the clipboard and use PasteFace to add the button image. > > See http://www.daveswebsite.com/article...1/default.shtml for a > C++ example and KB288771 for a VB example. Offhand I'm not familiar with > any C# examples but there may be some out there if you Google for > "PasteFace". > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
If you are using the Word editor (default in Outlook 2003), you cannot set
the image using Picture and Mask properties from a COM addin since IPicture interface cannot be marshalled across the process boundaries (Word inspectors run in the windword.exe process space), so you must use the PasteFace method. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Rog" <rog_21@yahoo.com> wrote in message news:eiG4ebESGHA.4688@TK2MSFTNGP11.phx.gbl... > Thanks Ken, so the mask is supported even on the inspector for Outlook > 2003? I know it works for the Explorer buttons. > Thanks > > Ken Slovak - [MVP - Outlook] wrote: >> Mask is supported for Outlook 2002 and later. It's only for Outlook 2000 >> that you need to use a workaround. Are you needing to support Outlook >> 2000? >> >> The trick with Outlook 2000 is to use one color as a mask color, say >> magenta. That color can only be used where you want masking. Then you do >> some fancy stuff with the Win32 API and separate the mask and image and >> pop them onto the clipboard and use PasteFace to add the button image. >> >> See http://www.daveswebsite.com/article...1/default.shtml for a C++ >> example and KB288771 for a VB example. Offhand I'm not familiar with any >> C# examples but there may be some out there if you Google for >> "PasteFace". >> |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Thanks Dmitry, that then supports what I saw when I tried to the use
mask on the Button and get an exception. Do you know how I can get a transparent image onto the CommandBarButton using PasteFace then. I used magenta and green as the background, but it does not work. I am using C#. Thanks, Rog Dmitry Streblechenko wrote: > If you are using the Word editor (default in Outlook 2003), you cannot set > the image using Picture and Mask properties from a COM addin since IPicture > interface cannot be marshalled across the process boundaries (Word > inspectors run in the windword.exe process space), so you must use the > PasteFace method. > > Dmitry Streblechenko (MVP) > http://www.dimastr.com/ > OutlookSpy - Outlook, CDO > and MAPI Developer Tool > > "Rog" <rog_21@yahoo.com> wrote in message > news:eiG4ebESGHA.4688@TK2MSFTNGP11.phx.gbl... >> Thanks Ken, so the mask is supported even on the inspector for Outlook >> 2003? I know it works for the Explorer buttons. >> Thanks >> >> Ken Slovak - [MVP - Outlook] wrote: >>> Mask is supported for Outlook 2002 and later. It's only for Outlook 2000 >>> that you need to use a workaround. Are you needing to support Outlook >>> 2000? >>> >>> The trick with Outlook 2000 is to use one color as a mask color, say >>> magenta. That color can only be used where you want masking. Then you do >>> some fancy stuff with the Win32 API and separate the mask and image and >>> pop them onto the clipboard and use PasteFace to add the button image. >>> >>> See http://www.daveswebsite.com/article...1/default.shtml for a C++ >>> example and KB288771 for a VB example. Offhand I'm not familiar with any >>> C# examples but there may be some out there if you Google for >>> "PasteFace". >>> > > |
|
|
|
#6 |
|
Guest
Posts: n/a
|
I usually create a temp bitmap, paint the background with the current
scheme's dialog background color, then paint an icon on top of it. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Rog" <rog_21@yahoo.com> wrote in message news:%23J%23E$IHSGHA.5908@TK2MSFTNGP14.phx.gbl... > Thanks Dmitry, that then supports what I saw when I tried to the use mask > on the Button and get an exception. > Do you know how I can get a transparent image onto the CommandBarButton > using PasteFace then. I used magenta and green as the background, but it > does not work. I am using C#. > Thanks, > Rog > > > Dmitry Streblechenko wrote: >> If you are using the Word editor (default in Outlook 2003), you cannot >> set the image using Picture and Mask properties from a COM addin since >> IPicture interface cannot be marshalled across the process boundaries >> (Word inspectors run in the windword.exe process space), so you must use >> the PasteFace method. >> >> Dmitry Streblechenko (MVP) >> http://www.dimastr.com/ >> OutlookSpy - Outlook, CDO >> and MAPI Developer Tool >> >> "Rog" <rog_21@yahoo.com> wrote in message >> news:eiG4ebESGHA.4688@TK2MSFTNGP11.phx.gbl... >>> Thanks Ken, so the mask is supported even on the inspector for Outlook >>> 2003? I know it works for the Explorer buttons. >>> Thanks >>> >>> Ken Slovak - [MVP - Outlook] wrote: >>>> Mask is supported for Outlook 2002 and later. It's only for Outlook >>>> 2000 that you need to use a workaround. Are you needing to support >>>> Outlook 2000? >>>> >>>> The trick with Outlook 2000 is to use one color as a mask color, say >>>> magenta. That color can only be used where you want masking. Then you >>>> do some fancy stuff with the Win32 API and separate the mask and image >>>> and pop them onto the clipboard and use PasteFace to add the button >>>> image. >>>> >>>> See http://www.daveswebsite.com/article...1/default.shtml for a >>>> C++ example and KB288771 for a VB example. Offhand I'm not familiar >>>> with any C# examples but there may be some out there if you Google for >>>> "PasteFace". >>>> >> |
|
|
|
#7 |
|
Guest
Posts: n/a
|
One option is to translate the C++ example that Ken pointed you to, which creates a transparent icon on the clipboard that you can use for PasteFace.
Another option is to create a transparent icon and save it in a resource file in your assembly. When you need the image for your command bar button you can extract the icon resource as a Drawing.Icon object, call the Icon object's ToBitmap method to get a bitmap, and copy that to the clipboard where you can use it for PasteFace. You have to be careful when using the Clipboard not to clobber whatever data the user might currently have stored on it. Here is a VB.NET procedure that maintains the existing content when using PasteFace ''' <summary> ''' Preserve contents of clipboard while using PastFace to set button image ''' </summary> ''' <param name="cbb">CommandBar button getting the image</param> ''' <param name="bmpImage">Bitmap applied as button image</param> Private Sub PasteImage(ByVal cbb As CommandBarButton, ByVal bmpImage As Drawing.Bitmap) Try 'save current data (in all of its formats) on the clipboard; 'don't interfere with user pasting something into a new email Dim clipData As System.Windows.Forms.IDataObject = _ System.Windows.Forms.Clipboard.GetDataObject Dim astrFormats() As String = clipData.GetFormats(False) Dim savedData As System.Windows.Forms.IDataObject = New System.Windows.Forms.DataObject Dim i As Integer ' add data to new data object in reverse order ' that's how it went into current object For i = astrFormats.Length - 1 To 0 Step -1 savedData.SetData(astrFormats(i), clipData.GetData(astrFormats(i))) Next System.Windows.Forms.Clipboard.SetDataObject(bmpImage, False) 'PasteFace copies image to our button cbb.PasteFace() 'restore original data to clipboard System.Windows.Forms.Clipboard.SetDataObject(savedData) Catch ex As Exception 'exception handling here End Try End Sub "Rog" <rog_21@yahoo.com> wrote in message news:%23J%23E$IHSGHA.5908@TK2MSFTNGP14.phx.gbl... > Thanks Dmitry, that then supports what I saw when I tried to the use > mask on the Button and get an exception. > Do you know how I can get a transparent image onto the CommandBarButton > using PasteFace then. I used magenta and green as the background, but it > does not work. I am using C#. > Thanks, > Rog > > > Dmitry Streblechenko wrote: >> If you are using the Word editor (default in Outlook 2003), you cannot set >> the image using Picture and Mask properties from a COM addin since IPicture >> interface cannot be marshalled across the process boundaries (Word >> inspectors run in the windword.exe process space), so you must use the >> PasteFace method. >> >> Dmitry Streblechenko (MVP) >> http://www.dimastr.com/ >> OutlookSpy - Outlook, CDO >> and MAPI Developer Tool >> >> "Rog" <rog_21@yahoo.com> wrote in message >> news:eiG4ebESGHA.4688@TK2MSFTNGP11.phx.gbl... >>> Thanks Ken, so the mask is supported even on the inspector for Outlook >>> 2003? I know it works for the Explorer buttons. >>> Thanks >>> >>> Ken Slovak - [MVP - Outlook] wrote: >>>> Mask is supported for Outlook 2002 and later. It's only for Outlook 2000 >>>> that you need to use a workaround. Are you needing to support Outlook >>>> 2000? >>>> >>>> The trick with Outlook 2000 is to use one color as a mask color, say >>>> magenta. That color can only be used where you want masking. Then you do >>>> some fancy stuff with the Win32 API and separate the mask and image and >>>> pop them onto the clipboard and use PasteFace to add the button image. >>>> >>>> See http://www.daveswebsite.com/article...1/default.shtml for a C++ >>>> example and KB288771 for a VB example. Offhand I'm not familiar with any >>>> C# examples but there may be some out there if you Google for >>>> "PasteFace". >>>> >> >> |
|
|
|
#8 |
|
Guest
Posts: n/a
|
Thanks everyone, I will let you know what I end up doing.
Dave Kane [MVP - Outlook] wrote: > One option is to translate the C++ example that Ken pointed you to, > which creates a transparent icon on the clipboard that you can use for > PasteFace. > > Another option is to create a transparent icon and save it in a resource > file in your assembly. When you need the image for your command bar > button you can extract the icon resource as a Drawing.Icon object, call > the Icon object's ToBitmap method to get a bitmap, and copy that to the > clipboard where you can use it for PasteFace. > > You have to be careful when using the Clipboard not to clobber whatever > data the user might currently have stored on it. Here is a VB.NET > procedure that maintains the existing content when using PasteFace > > ''' <summary> > > ''' Preserve contents of clipboard while using PastFace to set button image > > ''' </summary> > > ''' <param name="cbb">CommandBar button getting the image</param> > > ''' <param name="bmpImage">Bitmap applied as button image</param> > > Private Sub PasteImage(ByVal cbb As CommandBarButton, ByVal bmpImage As > Drawing.Bitmap) > > Try > > 'save current data (in all of its formats) on the clipboard; > > 'don't interfere with user pasting something into a new email > > Dim clipData As System.Windows.Forms.IDataObject = _ > System.Windows.Forms.Clipboard.GetDataObject > > Dim astrFormats() As String = clipData.GetFormats(False) > > Dim savedData As System.Windows.Forms.IDataObject = New > System.Windows.Forms.DataObject > > Dim i As Integer > > ' add data to new data object in reverse order > > ' that's how it went into current object > > For i = astrFormats.Length - 1 To 0 Step -1 > > savedData.SetData(astrFormats(i), > clipData.GetData(astrFormats(i))) > > Next > > System.Windows.Forms.Clipboard.SetDataObject(bmpImage, False) > > 'PasteFace copies image to our button > > cbb.PasteFace() > > 'restore original data to clipboard > > System.Windows.Forms.Clipboard.SetDataObject(savedData) > > Catch ex As Exception > > 'exception handling here > > End Try > > End Sub > > > "Rog" <rog_21@yahoo.com <mailto:rog_21@yahoo.com>> wrote in message > news:%23J%23E$IHSGHA.5908@TK2MSFTNGP14.phx.gbl... > > Thanks Dmitry, that then supports what I saw when I tried to the use > > mask on the Button and get an exception. > > Do you know how I can get a transparent image onto the CommandBarButton > > using PasteFace then. I used magenta and green as the background, but it > > does not work. I am using C#. > > Thanks, > > Rog > > > > > > Dmitry Streblechenko wrote: > >> If you are using the Word editor (default in Outlook 2003), you > cannot set > >> the image using Picture and Mask properties from a COM addin since > IPicture > >> interface cannot be marshalled across the process boundaries (Word > >> inspectors run in the windword.exe process space), so you must use the > >> PasteFace method. > >> > >> Dmitry Streblechenko (MVP) > >> http://www.dimastr.com/ > >> OutlookSpy - Outlook, CDO > >> and MAPI Developer Tool > >> > >> "Rog" <rog_21@yahoo.com <mailto:rog_21@yahoo.com>> wrote in message > >> news:eiG4ebESGHA.4688@TK2MSFTNGP11.phx.gbl... > >>> Thanks Ken, so the mask is supported even on the inspector for Outlook > >>> 2003? I know it works for the Explorer buttons. > >>> Thanks > >>> > >>> Ken Slovak - [MVP - Outlook] wrote: > >>>> Mask is supported for Outlook 2002 and later. It's only for > Outlook 2000 > >>>> that you need to use a workaround. Are you needing to support Outlook > >>>> 2000? > >>>> > >>>> The trick with Outlook 2000 is to use one color as a mask color, say > >>>> magenta. That color can only be used where you want masking. Then > you do > >>>> some fancy stuff with the Win32 API and separate the mask and > image and > >>>> pop them onto the clipboard and use PasteFace to add the button image. > >>>> > >>>> See http://www.daveswebsite.com/article...1/default.shtml > for a C++ > >>>> example and KB288771 for a VB example. Offhand I'm not familiar > with any > >>>> C# examples but there may be some out there if you Google for > >>>> "PasteFace". > >>>> > >> > >> |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

