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

Method SetImage

button.go:81–113  ·  view source on GitHub ↗
(image Image)

Source from the content-addressed store, hash-verified

79}
80
81func (b *Button) SetImage(image Image) error {
82 var typ, handle uintptr
83 switch img := image.(type) {
84 case nil:
85
86 case *Bitmap:
87 typ = win.IMAGE_BITMAP
88 handle = uintptr(img.hBmp)
89
90 case *Icon:
91 typ = win.IMAGE_ICON
92 handle = uintptr(img.handleForDPI(b.DPI()))
93
94 default:
95 bmp, err := iconCache.Bitmap(image, b.DPI())
96 if err != nil {
97 return err
98 }
99
100 typ = win.IMAGE_BITMAP
101 handle = uintptr(bmp.hBmp)
102 }
103
104 b.SendMessage(win.BM_SETIMAGE, typ, handle)
105
106 b.image = image
107
108 b.RequestLayout()
109
110 b.imageChangedPublisher.Publish()
111
112 return nil
113}
114
115func (b *Button) ImageChanged() *Event {
116 return b.imageChangedPublisher.Event()

Callers 5

initMethod · 0.95
ApplyDPIMethod · 0.95
SetImageAboveTextMethod · 0.45
SetImageAboveTextMethod · 0.45
setActionImageFunction · 0.45

Calls 6

handleForDPIMethod · 0.65
DPIMethod · 0.65
SendMessageMethod · 0.65
RequestLayoutMethod · 0.65
BitmapMethod · 0.45
PublishMethod · 0.45

Tested by

no test coverage detected