MCPcopy Index your code
hub / github.com/lxn/walk / setText

Method setText

tooltip.go:222–246  ·  view source on GitHub ↗
(hwnd win.HWND, text string)

Source from the content-addressed store, hash-verified

220}
221
222func (tt *ToolTip) setText(hwnd win.HWND, text string) error {
223 ti := tt.toolInfo(hwnd)
224 if ti == nil {
225 return newError("unknown tool")
226 }
227
228 n := 0
229 for i, r := range text {
230 if r < 0x10000 {
231 n++
232 } else {
233 n += 2 // surrogate pair
234 }
235 if n >= maxToolTipTextLen {
236 text = text[:i]
237 break
238 }
239 }
240
241 ti.LpszText = syscall.StringToUTF16Ptr(text)
242
243 tt.SendMessage(win.TTM_SETTOOLINFO, 0, uintptr(unsafe.Pointer(ti)))
244
245 return nil
246}
247
248func (tt *ToolTip) toolInfo(hwnd win.HWND) *win.TOOLINFO {
249 var ti win.TOOLINFO

Callers 1

SetTextMethod · 0.95

Calls 3

toolInfoMethod · 0.95
newErrorFunction · 0.85
SendMessageMethod · 0.65

Tested by

no test coverage detected