我需要写辉光在VISTA / 7的玻璃窗口中的文字,而我,试图调用API来有写一些文字。我已签出一个伟大的样品,但问题是,我使用.NET 1(请不要问: - )
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 :-)
我需要翻译follwing .NET 2 code到PInvoke的,.NET 1 code。有人可以帮助?
I need to translate the follwing .NET 2 code to PInvoke, .NET 1 code. Someone could help?
// 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);
类 VisualStyleRenderer
不在.NET 1存在,所以我需要获得 renderer.Handle
的另一种方式。有人可以帮忙吗?
The class VisualStyleRenderer
does not exist in .NET 1, so I need to get the renderer.Handle
in other way. Somebody could help?
在此先感谢。
定义OpenThemeData API和DrawThemeTextEx,以及一些必需的结构和常量:
Define the OpenThemeData API and DrawThemeTextEx, as well as some required structs and constants:
[DllImport("uxtheme.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr OpenThemeData(IntPtr hwnd, string pszClassList);
[DllImport("uxtheme.dll", CharSet = CharSet.Unicode)]
private extern static Int32 DrawThemeTextEx(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, string pszText, int iCharCount, uint flags, ref RECT rect, ref DTTOPTS poptions);
[StructLayout(LayoutKind.Sequential)]
private struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
[StructLayout(LayoutKind.Sequential)]
private struct DTTOPTS
{
public int dwSize;
public int dwFlags;
public int crText;
public int crBorder;
public int crShadow;
public int iTextShadowType;
public int ptShadowOffsetX;
public int ptShadowOffsetY;
public int iBorderSize;
public int iFontPropId;
public int iColorPropId;
public int iStateId;
public bool fApplyOverlay;
public int iGlowSize;
public IntPtr pfnDrawTextCallback;
public IntPtr lParam;
}
// taken from vsstyle.h
private const int WP_CAPTION = 1;
private const int CS_ACTIVE = 1;
然后,调用它是这样的:
And then, call it like this:
IntPtr handle = OpenThemeData(IntPtr.Zero, "WINDOW");
DrawThemeTextExt(handle, hdc, WS_CAPTION, CS_ACTIVE, ...)
在WS_CAPTION和CS_ACTIVE值相等.NET分别激活2的标题和。值进行正式描述:部件和状态
上一篇:自定义窗体设计器使用Visual C#.NET窗体、自定义、NET、Visual
下一篇:有没有一种办法"提取"的前pression WPF控件混合?控件、办法、pression、QUOT