Question

I'm almost certain I know the answer to this question, but I'm hoping there's something I've overlooked.

Certain applications seem to have the Vista Aero look and feel to their caption bars and buttons even when running on Windows XP. (Google Chrome and Windows Live Photo Gallery come to mind as examples.) I know that one way to accomplish this from WinForms would be to create a borderless form and draw the caption bar/buttons yourself, then overriding WndProc to make sure moving, resizing, and button clicks do what they're supposed to do (I'm not clear on the specifics but could probably pull it off given a day to read documentation.) I'm curious if there's a different, easier way that I'm overlooking. Perhaps some API calls or window styles I've overlooked?

I believe Google has answered it for me by using the roll-your-own-window approach with Chrome. I will leave the question open for another day in case someone has new information, but I believe I have answered the question myself.

Was it helpful?

Solution

Here's an article with full code sample on how to use your own custom "chrome" for an application:

http://geekswithblogs.net/kobush/articles/CustomBorderForms3.aspx

This looks like some really good stuff. There are a total of 3 articles in it's series, and it runs great, and on Vista too!

OTHER TIPS

Google Chrome is not using the Vista SDK to achieve this on XP. If you peek into src\chrome\browser\views\frame there are several files to define the browser frame depending on the capabilities of the system. On XP, it looks like OpaqueFrame is used; line 19 has this to say:

// OpaqueFrame
//
//  OpaqueFrame is a CustomFrameWindow subclass that in conjunction with
//  OpaqueNonClientView provides the window frame on Windows XP and on Windows
//  Vista when DWM desktop compositing is disabled. The window title and
//  borders are provided with bitmaps.

It looks like it's using the resources in src\chrome\app\theme to draw the frame buttons.

So it looks like my hopes that there's some kind of cheap way to enable Vista theming on XP are dashed. The only way to do it is to manually draw the non-client area of your window. I believe something like this is probably the right track, since it lets Windows handle the non-client stuff like moving and resizing the window.

Unless someone can find a method to magically enable the Vista theming on XP, this is the answer to the question but I obviously cannot mark my own post as the answer.

Owen, I'm using Chrome on XP and I don't see "Vista Aero" glass theme on the Chrome window. I see it as solid blue.

If it's custom theming of controls and windows title bars you want, that can be accomplished. There's an excellent, free UI toolkit for WinForms that does exactly that: KryptonToolkit

@Jonathan Holland: Is this something that can be done from .NET?

Yes, using DllImport. Here is a good blog post

Google Chrome uses the Windows Vista SDK to get the glass look on XP. You can download it here:

http://www.microsoft.com/downloads/details.aspx?FamilyID=4377f86d-c913-4b5c-b87e-ef72e5b4e065&displaylang=en

Using this, you need to enabled delay loading of the following DLL's to get the Glass Effect in XP:

  • uxtheme.dll
  • dwmapi.dl

Nope, I am afraid, there is no other easy way of doing this.

You are on the right track. You will need to create a custom Winform and then proceed as illustrated in this example.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top