Skip to content

Commit

Permalink
TableView: Fix StretchLastColumn regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
lxn committed Oct 29, 2019
1 parent b531841 commit c9d61f7
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions tableview.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ type TableView struct {
inSetCurrentIndex bool
inMouseEvent bool
hasFrozenColumn bool
inEraseBkgnd bool
busyStretchingLastColumn bool
focused bool
ignoreNowhere bool
updateLVSizesNeedsSpecialCare bool
Expand Down Expand Up @@ -1415,7 +1415,7 @@ func (tv *TableView) StretchLastColumn() error {
}

var hwnd win.HWND
if tv.visibleColumnCount()-tv.visibleFrozenColumnCount() == 0 {
if colCount-tv.visibleFrozenColumnCount() == 0 {
hwnd = tv.hwndFrozenLV
} else {
hwnd = tv.hwndNormalLV
Expand All @@ -1425,7 +1425,7 @@ func (tv *TableView) StretchLastColumn() error {
lastIndexInLV := -1
var lastIndexInLVWidth int
for _, tvc := range tv.columns.items {
colWidth := tvc.Width()
colWidth := tv.IntFrom96DPI(tvc.Width())
if index := tvc.indexInListView(); int(index) > lastIndexInLV {
lastIndexInLV = int(index)
lastIndexInLVWidth = colWidth
Expand Down Expand Up @@ -1824,15 +1824,16 @@ func (tv *TableView) lvWndProc(origWndProcPtr uintptr, hwnd win.HWND, msg uint32
hwndOther = tv.hwndFrozenLV
}

if tv.lastColumnStretched && !tv.busyStretchingLastColumn && tv.visibleColumnCount()-tv.visibleFrozenColumnCount() > 0 == (hwnd == tv.hwndNormalLV) {
tv.busyStretchingLastColumn = true
defer func() {
tv.busyStretchingLastColumn = false
}()
tv.StretchLastColumn()
}

switch msg {
case win.WM_ERASEBKGND:
if tv.lastColumnStretched && !tv.inEraseBkgnd {
tv.inEraseBkgnd = true
defer func() {
tv.inEraseBkgnd = false
}()
tv.StretchLastColumn()
}
return 1

case win.WM_GETDLGCODE:
Expand Down

0 comments on commit c9d61f7

Please sign in to comment.