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

Function NewTableViewWithCfg

tableview.go:146–330  ·  view source on GitHub ↗

NewTableViewWithCfg creates and returns a *TableView as child of the specified Container and with the provided additional configuration.

(parent Container, cfg *TableViewCfg)

Source from the content-addressed store, hash-verified

144// NewTableViewWithCfg creates and returns a *TableView as child of the specified
145// Container and with the provided additional configuration.
146func NewTableViewWithCfg(parent Container, cfg *TableViewCfg) (*TableView, error) {
147 tv := &TableView{
148 imageUintptr2Index: make(map[uintptr]int32),
149 filePath2IconIndex: make(map[string]int32),
150 formActivatingHandle: -1,
151 customHeaderHeight: cfg.CustomHeaderHeight,
152 customRowHeight: cfg.CustomRowHeight,
153 scrollbarOrientation: Horizontal | Vertical,
154 restoringCurrentItemOnReset: true,
155 }
156
157 tv.columns = newTableViewColumnList(tv)
158
159 if err := InitWidget(
160 tv,
161 parent,
162 tableViewWindowClass,
163 win.WS_BORDER|win.WS_VISIBLE,
164 win.WS_EX_CONTROLPARENT); err != nil {
165 return nil, err
166 }
167
168 succeeded := false
169 defer func() {
170 if !succeeded {
171 tv.Dispose()
172 }
173 }()
174
175 var rowHeightStyle uint32
176 if cfg.CustomRowHeight > 0 {
177 rowHeightStyle = win.LVS_OWNERDRAWFIXED
178 }
179
180 if tv.hwndFrozenLV = win.CreateWindowEx(
181 0,
182 syscall.StringToUTF16Ptr("SysListView32"),
183 nil,
184 win.WS_CHILD|win.WS_CLIPSIBLINGS|win.WS_TABSTOP|win.WS_VISIBLE|win.LVS_OWNERDATA|win.LVS_REPORT|cfg.Style|rowHeightStyle,
185 win.CW_USEDEFAULT,
186 win.CW_USEDEFAULT,
187 win.CW_USEDEFAULT,
188 win.CW_USEDEFAULT,
189 tv.hWnd,
190 0,
191 0,
192 nil,
193 ); tv.hwndFrozenLV == 0 {
194 return nil, newError("creating frozen lv failed")
195 }
196
197 tv.frozenLVOrigWndProcPtr = win.SetWindowLongPtr(tv.hwndFrozenLV, win.GWLP_WNDPROC, tableViewFrozenLVWndProcPtr)
198 if tv.frozenLVOrigWndProcPtr == 0 {
199 return nil, lastError("SetWindowLongPtr")
200 }
201
202 tv.hwndFrozenHdr = win.HWND(win.SendMessage(tv.hwndFrozenLV, win.LVM_GETHEADER, 0, 0))
203 tv.frozenHdrOrigWndProcPtr = win.SetWindowLongPtr(tv.hwndFrozenHdr, win.GWLP_WNDPROC, tableViewHdrWndProcPtr)

Callers 1

NewTableViewWithStyleFunction · 0.85

Calls 15

DisposeMethod · 0.95
SetPersistentMethod · 0.95
applyFontMethod · 0.95
ApplySysColorsMethod · 0.95
ColumnsOrderableMethod · 0.95
SetColumnsOrderableMethod · 0.95
ColumnsSizableMethod · 0.95
SetColumnsSizableMethod · 0.95
CurrentIndexMethod · 0.95
SetCurrentIndexMethod · 0.95
CurrentIndexChangedMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…