PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook Program Addins Transparent Inspector images

Reply

Transparent Inspector images

 
Thread Tools Rate Thread
Old 15-03-2006, 03:11 PM   #1
Rog
Guest
 
Posts: n/a
Default Transparent Inspector images


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
  Reply With Quote
Old 15-03-2006, 03:29 PM   #2
Ken Slovak - [MVP - Outlook]
Guest
 
Posts: n/a
Default Re: Transparent Inspector images

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


  Reply With Quote
Old 15-03-2006, 03:41 PM   #3
Rog
Guest
 
Posts: n/a
Default Re: Transparent Inspector images

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".
>

  Reply With Quote
Old 15-03-2006, 06:57 PM   #4
Dmitry Streblechenko
Guest
 
Posts: n/a
Default Re: Transparent Inspector images

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".
>>



  Reply With Quote
Old 15-03-2006, 08:51 PM   #5
Rog
Guest
 
Posts: n/a
Default Re: Transparent Inspector images

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".
>>>

>
>

  Reply With Quote
Old 15-03-2006, 09:26 PM   #6
Dmitry Streblechenko
Guest
 
Posts: n/a
Default Re: Transparent Inspector images

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".
>>>>

>>


  Reply With Quote
Old 15-03-2006, 09:45 PM   #7
Dave Kane [MVP - Outlook]
Guest
 
Posts: n/a
Default Re: Transparent Inspector images

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".
>>>>

>>
>>

  Reply With Quote
Old 15-03-2006, 09:52 PM   #8
Rog
Guest
 
Posts: n/a
Default Re: Transparent Inspector images

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".
> >>>>
> >>
> >>

  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off