我如何创建一个没有菜单、栏、框架、3D 效果等的 Window,并且其大小与另一个 window 完全相同?
How can I create an Window without menu, bar, frame, 3D effect...etc with exact same size of another window?
目前我正在尝试创建在指定进程的 Window 上生成的 WaterMark window。
下面的例子是指定了notepad.exe的程序的执行。
但是如果你仔细观察,你会发现 WaterMark Window 的大小实际上与原始 Window 的大小不一样。
我正在调整 Window 样式以弄清楚如何让我的水印 Window 的大小与原始 Window 的
完全相同
如果有人有建议,请帮助我。
下面是我设置 WaterMark Window 样式的代码。
void OnCmSetAttribute(void){ ModifyStyleEx( 0, WS_EX_LAYERED | WS_EX_TRANSPARENT); SetLayeredWindowAttributes(RGB(255,255,255), 204, LWA_ALPHA | LWA_COLORKEY);}
您可以使用 GetWindowRect
获得 window 尺寸。不过,您必须知道 window 处理程序。
要知道window句柄这里是一个小代码(你可以找到整个东西here。)
(不是编译代码。)
EnumWindows (&Enum, (LPARAM)&_windows);
BOOL CALLBACK Enum (HWND hwnd, LPARAM lParam)
{
WINDOWPLACEMENT place;
char window_title[200];
UINT class_length = 0;
UINT title_length = 0;
class_length = GetClassNameA(hwnd, buf, buf_size);
title_length = GetWindowTextA(hwnd, window_title, ARRAYSIZE(window_title));
GetWindowPlacement(hwnd, &place);
GetWindowRect(hWnd, &lpRect);
In Windows Vista and later, the Window Rect now includes the area occupied by the drop shadow.
To get the window bounds excluding the drop shadow, use DwmGetWindowAttribute
, specifying DWMWA_EXTENDED_FRAME_BOUNDS
.
目前我正在尝试创建在指定进程的 Window 上生成的 WaterMark window。
下面的例子是指定了notepad.exe的程序的执行。
但是如果你仔细观察,你会发现 WaterMark Window 的大小实际上与原始 Window 的大小不一样。
我正在调整 Window 样式以弄清楚如何让我的水印 Window 的大小与原始 Window 的
完全相同如果有人有建议,请帮助我。
下面是我设置 WaterMark Window 样式的代码。
void OnCmSetAttribute(void){ ModifyStyleEx( 0, WS_EX_LAYERED | WS_EX_TRANSPARENT); SetLayeredWindowAttributes(RGB(255,255,255), 204, LWA_ALPHA | LWA_COLORKEY);}
您可以使用 GetWindowRect
获得 window 尺寸。不过,您必须知道 window 处理程序。
要知道window句柄这里是一个小代码(你可以找到整个东西here。)
(不是编译代码。)
EnumWindows (&Enum, (LPARAM)&_windows);
BOOL CALLBACK Enum (HWND hwnd, LPARAM lParam)
{
WINDOWPLACEMENT place;
char window_title[200];
UINT class_length = 0;
UINT title_length = 0;
class_length = GetClassNameA(hwnd, buf, buf_size);
title_length = GetWindowTextA(hwnd, window_title, ARRAYSIZE(window_title));
GetWindowPlacement(hwnd, &place);
GetWindowRect(hWnd, &lpRect);
In Windows Vista and later, the Window Rect now includes the area occupied by the drop shadow. To get the window bounds excluding the drop shadow, use
DwmGetWindowAttribute
, specifyingDWMWA_EXTENDED_FRAME_BOUNDS
.