PropertySheet color for Outlook 2007

M

Mark Wilson

I have client extension for Outlook 2007 that displays a transparent icon on
a ProperySheet. I'm currently having issues in determining the color of the
propertysheet page (i.e. Tools/Options) when this addin is running under
Outlook 2007.

In Outlook XP and Outlook 2003 I get the background color of the underlying
page with

COLORREF PageColor;
PageColor = (COLORREF) GetSysColor(COLOR_BTNFACE);

However, when running Vista and Outlook 2007, the color for the
SysTabControl32 control is a different color than the background color of the
top level Options (#32770 Dialog) window. This also seems to happen with
Outlook 2007 and Widows XP if the window appearance is set to "Windows XP
Style".

I need to determine the color so I can set the appropriate transparent color
in my BMP image. If this is not a "System" color, is it hard coded in
Outlook 2007 or is it derived from some value?
 
K

Ken Slovak - [MVP - Outlook]

Why not just use a PNG image with a full transparency layer, then you don't
need to bother at all with the background color. I do that for images on
property pages and ribbon controls. I don't do it only for CommandBarButton
objects and such.
 
W

Wei Lu [MSFT]

Hi ,

How is everything going? Please feel free to let me know if you need any
assistance.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Mark Wilson

Hi Wei.

Ken's suggestion has merit. However I'm a bit stuck at the moment. I'm
working in C++ with VS2005.

In the resource editor I can add a Picture Control to the Propertysheet but
I can only insert an Icon or a BMP image into the control. It won't accept a
PNG image.

Previously I was using a BMP image that I modified with a BitBlt and set the
transparency color for the BMP to the same value as COLOR_BTNFACE.

The displayed BMP was transparent. I can reuse this code if I can determine
what the actual background color is.

If not, how do I put a PNG file onto the Propertysheet?
 
W

Wei Lu [MSFT]

Hello Mark,

Could you post a screenshot so that I could understand which color you want
better?

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
K

Ken Slovak - [MVP - Outlook]

I don't do C++ but what I do for a PNG is to add it to my resource file as a
CUSTOM resource with the image file stored as binary data. I then retrieve
it from the resource file and save it as a temp file somewhere and read it
back to provide the image data. That's with unmanaged code, in managed code
I have no problems adding a PNG to the project resources.
 
M

Mark Wilson

Hi Wei.

In Outlook 2003 I get the value of COLOR_BTNFACE and use that for the
transparent background in my image. The RGB value I get is EC, E9, D8. The
image looks like this and it seems the entire page page is set to that value.
http://www.markwilson.ca/Test/OL2003.png

However, in Outlook 2007 the value returned for COLOR_BTNFACE is F0, F0, F0
but the page seems to be white FF, FF, FF. The result looks like this:
http://www.markwilson.ca/Test/OL2007.png

You can see that the "123" image has had its background set to F0, F0, F0
but that is not the color of the background page. Hence, it appears as a
grey box on a white page.

Will the entire page of the Property Sheet be white for all color schemes in
Outlook 2007?
 
M

Mark Wilson

Hi Ken.

I have transparent bitmaps working on the Ribbon. I define a custom
resource called "IMAGE" and store a binary copy of the PNG file there. Then
using the "getImage" tag in my XML file I call a routine that retrieves that
information from the resource and returns it as a IPictureDisp. That works
fine and Outlook 2007 takes care of displaying the image.

What I don't understand how to do is place a PNG file on a Dialog. For an
Icon or a Bitmap I can stick it into a "Picture Control". Is there some
other control that I can add to the Dialog that will host a PNG image?
 
K

Ken Slovak - [MVP - Outlook]

I'm not sure about that but why do you need it in a control? Can't you just
access it from the project resources as a PNG file?
 
M

Mark Wilson

Well, I start with a blank Dialog in the Visual Studio resource editor and if
I want a Button I drag a button onto the Dialog from the Dialog Editor
Toolbox. If I want a an Edit Control I drag one of those into position. It
seemed to make sense to me that if I wanted an image I would add a Picture
Control to the Dialog.

I realize that you don't do C++ (and I don't do VB) but what mechanism would
you use to get a PNG image to show up on a Dialog?
 
K

Ken Slovak - [MVP - Outlook]

OK, I misread what you said about placing a PNG. It looks like a PictureBox
won't hold a PNG file. Offhand I don't know what other control could hold a
PNG, not one of the standard controls that come with VS. I suppose you could
load the PictureBox using code with a PNG, although I haven't tried it. You
could get the PNG from the project resources and convert it to a BMP using
AxHost or some other method.
 
M

Mark Wilson

Hi Wei. I have a better set of screen shots to explain the situation.

Look at http://www.markwilson.ca/Test/Windows_Standard.png
It is a Propertysheet with Vista set to the "Windows Standard" window style
and the "3D Objects" colour set to light blue. You can see that the
transparent image on the left is actually transparent and the standard BMP on
the right looks like a white rectangle. That's how it should work. However,
this is what I get when I change the window style to "Windows Vista Basic".

http://www.markwilson.ca/Test/Windows_Vista_basic.png

Transparency is still working but the colour showing up is the blue from the
main Dialog window, not the white on the "Test" tab. The image on the right
looks transparent but that is only because the background in the BMP file by
chance happens to be the same as that of the "Test" Propertysheet.

What could be causing this problem?

How can an Addin tell if the windows style is Standard or Vista Basic?
 
W

Wei Lu [MSFT]

Hello Mark,

I am still performing some research on this. I appreciate your patience.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Mark Wilson

Thanks for sticking with this.

If it helps, here is how I'm placing the BMP file in the Dialog.

case WM_PAINT:
{
PAINTSTRUCT ps;
HBITMAP hBitmap, hOldBitmap;
HPALETTE hPalette, hOldPalette;
HDC hDC, hMemDC;
BITMAP bm;

hDC = BeginPaint( hDlg, &ps );

if (LoadBitmapFromResource(&hBitmap, &hPalette ))
{
GetObject( hBitmap, sizeof(BITMAP), &bm );
hMemDC = CreateCompatibleDC( hDC );
hOldBitmap = (HBITMAP) SelectObject( hMemDC, hBitmap );
hOldPalette = SelectPalette( hDC, hPalette, FALSE );
RealizePalette( hDC );

iHorizontalPixels = GetDeviceCaps(GetDC(hDlg), LOGPIXELSX);
iVerticalPixels = GetDeviceCaps(GetDC(hDlg), LOGPIXELSY);
iX = MulDiv( 8, iHorizontalPixels, 96);
iY = MulDiv( 8, iVerticalPixels, 96);

BitBlt( hDC, iX, iY, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY );

SelectObject( hMemDC, hOldBitmap );
DeleteObject( hBitmap );
SelectPalette( hDC, hOldPalette, FALSE );
DeleteObject( hPalette );

DeleteDC( hMemDC );
}
EndPaint( hDlg, &ps );
}
 
M

Mark Wilson

OK. I'll look at that, but I think I'll be right back where I started. i.e.
putting a BMP onto the Dialog and having broken transparency if I'm using the
Windows Vista Basic windows style instead of the Windows Standard style.
 
W

Wei Lu [MSFT]

Hello,

The product team member I was consulting is out of office right now. Once
he comes back, I will update the information ASAP.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
W

Wei Lu [MSFT]

Hello Mark Wilson,

The internal team member suggest me to refer this article to determine what
color that area could be to handle it.

http://support.microsoft.com/kb/892462

Hope this article could help you to get the Color information to use.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Mark Wilson

Hi Wei.

Thanks for the information. Basically grab a copy of the desktop image as a
BMP and locate the mouse coordinates then read the pixel colour value there.
However, I don't know where the user is going to place the mouse and at this
point, even if I did know the colour value, I'm not sure how to use it.

The code snippet I posted on June 11 seems to be colour independent. It
should be able to determine the colour of the window area that BitBlt is
drawing on but for some reason it is getting the wrong colour as seen in this
image http://www.markwilson.ca/Test/Windows_Vista_basic.png

How do I make this transparency code work for Outlook 2007 PropertySheets
when the Windows style is Vista Basic? Is this the correct discussion group
for this question?
 
W

Wei Lu [MSFT]

Hello Mark,

So far, from my opinion, this issue may not related with Outlook and Com
add-in. It more like to related with the GDI API in Win32 development.

I would like to suggest you to use the AlphaBlend API in Windows GDI.

http://msdn2.microsoft.com/en-us/library/ms532324.aspx

The AlphaBlend function displays bitmaps that have transparent or
semitransparent pixels.

You may consulting this issue in the following newsgroups.

microsoft.public.win32.programmer.ui
or
microsoft.public.win32.programmer.gdi

Thank you!

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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