Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Add-ins for Outlook (http://www.outlookbanter.com/add-ins-outlook/)
-   -   Transparent Inspector images (http://www.outlookbanter.com/add-ins-outlook/8383-transparent-inspector-images.html)

Rog March 15th 06 04:11 PM

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

Ken Slovak - [MVP - Outlook] March 15th 06 04:29 PM

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/articles.../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" wrote in message
...
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



Rog March 15th 06 04:41 PM

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


Dmitry Streblechenko March 15th 06 07:57 PM

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" wrote in message
...
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/articles.../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".




Rog March 15th 06 09:51 PM

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" wrote in message
...
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/articles.../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".




Dmitry Streblechenko March 15th 06 10:26 PM

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" wrote in message
...
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" wrote in message
...
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/articles.../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".




Dave Kane [MVP - Outlook] March 15th 06 10:45 PM

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(bmpIm age, False)

'PasteFace copies image to our button

cbb.PasteFace()

'restore original data to clipboard

System.Windows.Forms.Clipboard.SetDataObject(saved Data)

Catch ex As Exception

'exception handling here

End Try

End Sub


"Rog" wrote in message ...
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" wrote in message
...
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/articles.../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".




Rog March 15th 06 10:52 PM

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(bmpIm age, False)

'PasteFace copies image to our button

cbb.PasteFace()

'restore original data to clipboard

System.Windows.Forms.Clipboard.SetDataObject(saved Data)

Catch ex As Exception

'exception handling here

End Try

End Sub


"Rog" wrote in message
...
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" wrote in message
...
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/articles.../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".





All times are GMT +1. The time now is 11:35 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com