forked from whtiehack/wingui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
image.go
62 lines (52 loc) · 1.48 KB
/
image.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package wingui
// https://www.daniweb.com/programming/software-development/code/216348/displaying-a-jpeg-image-using-windows-gui
import (
"github.com/lxn/win"
)
// Image a static image widget for Dialog.
type Image struct {
WindowBase
// OnClicked must set appearance Notify to true before use.
OnClicked func()
}
// WndProc Image window WndProc.
func (b *Image) WndProc(msg uint32, wParam, lParam uintptr) uintptr {
// log.Print("static msg", msg, wParam, lParam)
switch msg {
case win.WM_CTLCOLORSTATIC:
case win.WM_COMMAND:
if b.OnClicked != nil {
b.OnClicked()
}
break
}
return b.AsWindowBase().WndProc(msg, wParam, lParam)
}
// LoadBitmap show Bitmap on window. Don't forget to set the type to Bitmap
func (b *Image) LoadBitmap(bitmap win.HBITMAP) uintptr {
return b.SendMessage(0x172, win.IMAGE_BITMAP, uintptr(bitmap))
}
// NewImage create a new Image,need bind to Dialog before use.
func NewImage(idd uintptr) *Image {
return &Image{
WindowBase: WindowBase{idd: idd},
OnClicked: nil,
}
}
// BindNewStatic create a new Image and bind to target dlg.
func BindNewImage(idd uintptr, dlg *Dialog) (*Image, error) {
b := NewImage(idd)
err := dlg.BindWidgets(b)
return b, err
}
/*
// Static Control Mesages
#define STM_SETICON 0x0170
#define STM_GETICON 0x0171
#define STM_SETIMAGE 0x0172
#define STM_GETIMAGE 0x0173
#define STN_CLICKED 0
#define STN_DBLCLK 1
#define STN_ENABLE 2
#define STN_DISABLE 3
*/