diff options
| author | Pietro Gagliardi <[email protected]> | 2014-04-01 21:17:27 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-04-01 21:17:27 -0400 |
| commit | 8cb3991ef9245ebc84d3760bd2bb279b0a3e09ed (patch) | |
| tree | b05ceacb0d4425402fe988c5bbca2eb3921f2951 /prefsize_windows.go | |
| parent | af952325890580a63d821b03241480f91519e340 (diff) | |
Fixed Windows control sizing: turns out simply calling GetTextMetrics() was not enough, as the GetDC() functions don't load the control font into the DC; we have to do it ourselves with SelectObject() (according to GetTextMetrics()'s docs on MSDN). Upon re-evaluation, the only things that need custom fonts are menus and statusbars; I don't know if menus can be done with the standard contorls and statusbars change the font of all controls inside... so how fonts are handled in classData needs to change now.
Diffstat (limited to 'prefsize_windows.go')
| -rw-r--r-- | prefsize_windows.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/prefsize_windows.go b/prefsize_windows.go index 5a34032..9a16f8d 100644 --- a/prefsize_windows.go +++ b/prefsize_windows.go @@ -62,6 +62,7 @@ var stdDlgSizes = [nctypes]dlgunits{ } var ( + _selectObject = gdi32.NewProc("SelectObject") _getTextMetrics = gdi32.NewProc("GetTextMetricsW") _getWindowDC = user32.NewProc("GetWindowDC") _releaseDC = user32.NewProc("ReleaseDC") @@ -79,6 +80,12 @@ func (s *sysData) preferredSize() (width int, height int) { panic(fmt.Errorf("error getting DC for preferred size calculations: %v", err)) } dc = _HANDLE(r1) + r1, _, err = _selectObject.Call( + uintptr(dc), + uintptr(unsafe.Pointer(*classTypes[s.ctype].font))) + if r1 == 0 { // failure + panic(fmt.Errorf("error loading control font into device context for preferred size calculation: %v", err)) + } r1, _, err = _getTextMetrics.Call( uintptr(dc), uintptr(unsafe.Pointer(&tm))) |
