1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 11:32:48 -05:00

Windows: utility function to centre a window.

This was called from config box setup, and is obviously the kind of
thing that ought to be a reusable utility function.
This commit is contained in:
Simon Tatham
2022-04-24 13:34:15 +01:00
parent 69e8d471d1
commit cccdab9ba6
4 changed files with 25 additions and 13 deletions

View File

@ -0,0 +1,20 @@
/*
* Centre a window on the screen. Used to position the main config box.
*/
#include "putty.h"
void centre_window(HWND win)
{
RECT rd, rw;
if (!GetWindowRect(GetDesktopWindow(), &rd))
return;
if (!GetWindowRect(win, &rw))
return;
MoveWindow(win,
(rd.right + rd.left + rw.left - rw.right) / 2,
(rd.bottom + rd.top + rw.top - rw.bottom) / 2,
rw.right - rw.left, rw.bottom - rw.top, true);
}