「常に手前」をトグる
#include <windows.h> #include <tchar.h> int WinMain(HINSTANCE curr, HINSTANCE prev, LPSTR args, int stat) { if(__argc < 3){ char *buff = new char[strlen(*__argv) + 32]; wsprintf(buff, "usage: %s {+|-} {title} [class]", *__argv); MessageBoxA(NULL, buff, "topmost toggler", MB_OK); return 1; } SetWindowPos( FindWindow(__argv[3], __argv[2]), *__argv[1] == '-' ? HWND_NOTOPMOST : HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE); return 0; }
__argc と __argv を知る。WinMainの第三引数要らんやん。