I need to write a text with glow in a Vista/seven glass window, and I'm, trying to call the API to write some text there. I have checked out a great sample in CodeProject, but the problem is that I'm using .NET 1 (please, don't ask :-)
I need to translate the follwing .NET 2 code to PInvoke, .NET 1 code.
// using System.Windows.Forms.VisualStyles
VisualStyleRenderer renderer = new VisualStyleRenderer(
VisualStyleElement.Window.Caption.Active);
// call to UxTheme.dll
DrawThemeTextEx(renderer.Handle,
memoryHdc, 0, 0, text, -1, (int)flags,
ref textBounds, ref dttOpts);
The class VisualStyleRenderer
does not exist in .NET 1, so I need to get the renderer.Handle
in other way.
Define the OpenThemeData API and DrawThemeTextEx, as well as some required structs and constants:
And then, call it like this:
The WS_CAPTION and CS_ACTIVE values match .NET 2's Caption and Active respectively. Values are described here officially: Parts and States
In short, you get what you want by calling
OpenThemeData()
.To work out all the details it would be much easier for you to write a sample app in C++ to get to know how to drive the theme API from the ground up. There are many tutorials and lots of sample code on the web. But do it in C++ where you will have all the functions readily available. The last thing you want to get doing is fighting with P/Invokes whilst you are also getting to grips with low-level theme API.
Once you get it cracked in C++, then move on to the P/Invokes and if you have trouble it will be easy to refer back to the C++ code that works.