win32 c ++将窗口位置设置为右下角

问题描述 投票:0回答:1

如何在屏幕的右下角设置一个窗口(不包括任务栏)?我可以用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
        );
c++ windows winapi window hwnd
1个回答
0
投票

这是将窗口置于右下角的示例。 (在这里,我将窗口的宽度和高度都设置为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,但不必这样做:

创建具有扩展窗口的重叠窗口,弹出窗口或子窗口样式;否则,此功能与CreateWindow相同功能。

© www.soinside.com 2019 - 2024. All rights reserved.