你可以使用 'SetWindowPos' 函数将窗口置顶。以下是一个例子:

#include <windows.h>

int main() {
    HWND hWnd = FindWindow(NULL, 'Window Title'); // 替换 'Window Title' 为你的窗口标题
    if (hWnd != NULL) {
        SetForegroundWindow(hWnd); // 将窗口置于前台
        SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); // 设置窗口为顶层
    }
    return 0;
}

这段代码将找到标题为 'Window Title' 的窗口,将其置于前台并将其设置为顶层窗口。你需要将 'Window Title' 替换为你的窗口标题。

C++ 使用 SetWindowPos 将窗口置顶 (Windows)

原文地址: https://www.cveoy.top/t/topic/opN1 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录