From 4fa35b22391d56ba22725229f8d99f0061c910d0 Mon Sep 17 00:00:00 2001 From: papplampe Date: Tue, 10 Jun 2014 14:34:26 +0200 Subject: added Center function to window --- sysdata_windows.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'sysdata_windows.go') diff --git a/sysdata_windows.go b/sysdata_windows.go index 4a4f69f..76c068c 100644 --- a/sysdata_windows.go +++ b/sysdata_windows.go @@ -685,3 +685,15 @@ func (s *sysData) repaintAll() { } <-ret } + +func (s *sysData) center() { + var ws _RECT + _getWindowRect.Call(uintptr(s.hwnd), uintptr(unsafe.Pointer(&ws))) + dw, _, _ := _getSystemMetrics.Call(_SM_CXFULLSCREEN) + dh, _, _ := _getSystemMetrics.Call(_SM_CYFULLSCREEN) + ww := ws.right - ws.left + wh := ws.bottom - ws.top + wx := (int32(dw) / 2) - (ww / 2) + wy := (int32(dh) / 2) - (wh / 2) + s.setRect(int(wx), int(wy), int(ww), int(wh), 0) +} -- cgit v1.2.3