在 Windows 下窗口置顶的实现方法是使用 Win32 API 函数 SetWindowPos。
示例代码如下:
#include <Windows.h>
int main()
{
HWND hwnd = FindWindow(NULL, "窗口标题"); // 获取窗口句柄
if (hwnd != NULL)
{
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE)