diff options
author | Alexander Neumann <alexander.neumann@picos-software.com> | 2020-09-01 11:53:45 +0200 |
---|---|---|
committer | Alexander Neumann <alexander.neumann@picos-software.com> | 2020-09-01 11:53:45 +0200 |
commit | 6eca744e8e85c67bb570d383f46ddbc9a441e29e (patch) | |
tree | 627fb82ee43f92a86343c0d84a41f0e9bb9dd3a9 | |
parent | TableView: Reduce flicker (diff) | |
download | wireguard-windows-6eca744e8e85c67bb570d383f46ddbc9a441e29e.tar.xz wireguard-windows-6eca744e8e85c67bb570d383f46ddbc9a441e29e.zip |
Button: Fix weird BCM_GETIDEALSIZE issue with empty text
-rw-r--r-- | button.go | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -220,11 +220,16 @@ func (b *Button) WndProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr) uint // idealSize returns ideal button size in native pixels. func (b *Button) idealSize() Size { - var s win.SIZE + min := b.dialogBaseUnitsToPixels(Size{50, 14}) + + if b.Text() == "" { + return min + } + var s win.SIZE b.SendMessage(win.BCM_GETIDEALSIZE, 0, uintptr(unsafe.Pointer(&s))) - return maxSize(sizeFromSIZE(s), b.dialogBaseUnitsToPixels(Size{50, 14})) + return maxSize(sizeFromSIZE(s), min) } func (b *Button) CreateLayoutItem(ctx *LayoutContext) LayoutItem { |