-
Notifications
You must be signed in to change notification settings - Fork 45
/
progressbar.go
42 lines (32 loc) · 1.01 KB
/
progressbar.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
package gform
import (
"github.com/AllenDang/w32"
)
type ProgressBar struct {
W32Control
}
func NewProgressBar(parent Controller) *ProgressBar {
pb := new(ProgressBar)
pb.init(parent)
pb.SetSize(200, 25)
return pb
}
func (this *ProgressBar) init(parent Controller) {
this.W32Control.init(w32.PROGRESS_CLASS, parent, 0, w32.WS_CHILD|w32.WS_VISIBLE)
RegMsgHandler(this)
}
func (this *ProgressBar) Value() uint {
ret := w32.SendMessage(this.hwnd, w32.PBM_GETPOS, 0, 0)
return uint(ret)
}
func (this *ProgressBar) SetValue(v uint) {
w32.SendMessage(this.hwnd, w32.PBM_SETPOS, uintptr(v), 0)
}
func (this *ProgressBar) Range() (min, max uint) {
min = uint(w32.SendMessage(this.hwnd, w32.PBM_GETRANGE, uintptr(w32.BoolToBOOL(true)), 0))
max = uint(w32.SendMessage(this.hwnd, w32.PBM_GETRANGE, uintptr(w32.BoolToBOOL(false)), 0))
return
}
func (this *ProgressBar) SetRange(min, max uint) {
w32.SendMessage(this.hwnd, w32.PBM_SETRANGE32, uintptr(min), uintptr(max))
}