diff options
Diffstat (limited to 'windows/utils/centre_window.c')
-rw-r--r-- | windows/utils/centre_window.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/windows/utils/centre_window.c b/windows/utils/centre_window.c new file mode 100644 index 00000000..651fc279 --- /dev/null +++ b/windows/utils/centre_window.c @@ -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); +} |