MCPcopy
hub / github.com/lxn/walk / StretchLastColumn

Method StretchLastColumn

tableview.go:1512–1574  ·  view source on GitHub ↗

StretchLastColumn makes the last column take up all remaining horizontal space of the *TableView. The effect of this is not persistent.

()

Source from the content-addressed store, hash-verified

1510//
1511// The effect of this is not persistent.
1512func (tv *TableView) StretchLastColumn() error {
1513 colCount := tv.visibleColumnCount()
1514 if colCount == 0 {
1515 return nil
1516 }
1517
1518 var hwnd win.HWND
1519 frozenColCount := tv.visibleFrozenColumnCount()
1520 if colCount-frozenColCount == 0 {
1521 hwnd = tv.hwndFrozenLV
1522 colCount = frozenColCount
1523 } else {
1524 hwnd = tv.hwndNormalLV
1525 colCount -= frozenColCount
1526 }
1527
1528 var lp uintptr
1529 if tv.scrollbarOrientation&Horizontal != 0 {
1530 lp = win.LVSCW_AUTOSIZE_USEHEADER
1531 } else {
1532 width := tv.ClientBoundsPixels().Width
1533
1534 lastIndexInLV := -1
1535 var lastIndexInLVWidth int
1536
1537 for _, tvc := range tv.columns.items {
1538 var offset int
1539 if !tvc.Frozen() {
1540 offset = frozenColCount
1541 }
1542
1543 colWidth := tv.IntFrom96DPI(tvc.Width())
1544 width -= colWidth
1545
1546 if index := int32(offset) + tvc.indexInListView(); int(index) > lastIndexInLV {
1547 lastIndexInLV = int(index)
1548 lastIndexInLVWidth = colWidth
1549 }
1550 }
1551
1552 width += lastIndexInLVWidth
1553
1554 if hasWindowLongBits(tv.hwndNormalLV, win.GWL_STYLE, win.WS_VSCROLL) {
1555 width -= int(win.GetSystemMetricsForDpi(win.SM_CXVSCROLL, uint32(tv.DPI())))
1556 }
1557
1558 lp = uintptr(maxi(0, width))
1559 }
1560
1561 if lp > 0 {
1562 if 0 == win.SendMessage(hwnd, win.LVM_SETCOLUMNWIDTH, uintptr(colCount-1), lp) {
1563 return newError("LVM_SETCOLUMNWIDTH failed")
1564 }
1565
1566 if dpi := tv.DPI(); dpi != tv.dpiOfPrevStretchLastColumn {
1567 tv.dpiOfPrevStretchLastColumn = dpi
1568
1569 tv.Invalidate()

Callers 2

lvWndProcMethod · 0.95

Calls 13

visibleColumnCountMethod · 0.95
InvalidateMethod · 0.95
hasWindowLongBitsFunction · 0.85
maxiFunction · 0.85
newErrorFunction · 0.85
FrozenMethod · 0.80
IntFrom96DPIMethod · 0.80
indexInListViewMethod · 0.80
ClientBoundsPixelsMethod · 0.65
WidthMethod · 0.65
DPIMethod · 0.65

Tested by

no test coverage detected