win32 c++ set window 位置到右下角
win32 c++ set window location to the right-down corner
如何设置window到屏幕右下角(不包括任务栏)?我可以用 CreateWindowEx 完成吗?但是我只看到了CW_USEDEFAULT并没有CW_设置到角落里
HWND hwnd = CreateWindowEx(
NULL,
DUCKPROC_CLASS_NAME,
DUCKPROC_WINDOW_TIP_NAME,
WS_BORDER| WS_VISIBLE,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
GetModuleHandle(NULL),
NULL
);
这是将 window 放在右下角的示例。 (这里我设置window的宽高都是200。)
RECT desktopRect;
if (!GetWindowRect(GetDesktopWindow(), &desktopRect))
return FALSE;
int windowWidth = 200;
int windowHeight = 200;
int posX = desktopRect.right - windowWidth;
int posY = desktopRect.bottom - windowHeight;
HWND hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
posX, posY, windowWidth, windowHeight, nullptr, nullptr, hInstance, nullptr);
您可以使用 CreateWindowEx,但您不必这样做,因为:
Creates an overlapped, pop-up, or child window with an extended window
style; otherwise, this function is identical to the CreateWindow
function.
如何设置window到屏幕右下角(不包括任务栏)?我可以用 CreateWindowEx 完成吗?但是我只看到了CW_USEDEFAULT并没有CW_设置到角落里
HWND hwnd = CreateWindowEx(
NULL,
DUCKPROC_CLASS_NAME,
DUCKPROC_WINDOW_TIP_NAME,
WS_BORDER| WS_VISIBLE,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
GetModuleHandle(NULL),
NULL
);
这是将 window 放在右下角的示例。 (这里我设置window的宽高都是200。)
RECT desktopRect;
if (!GetWindowRect(GetDesktopWindow(), &desktopRect))
return FALSE;
int windowWidth = 200;
int windowHeight = 200;
int posX = desktopRect.right - windowWidth;
int posY = desktopRect.bottom - windowHeight;
HWND hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
posX, posY, windowWidth, windowHeight, nullptr, nullptr, hInstance, nullptr);
您可以使用 CreateWindowEx,但您不必这样做,因为:
Creates an overlapped, pop-up, or child window with an extended window style; otherwise, this function is identical to the CreateWindow function.