Skip to content

Instantly share code, notes, and snippets.

@andlabs
Created March 12, 2014 22:39
Show Gist options
  • Save andlabs/9518033 to your computer and use it in GitHub Desktop.
Save andlabs/9518033 to your computer and use it in GitHub Desktop.
func (s *sysData) setProgress(percent int) {
ret := make(chan uiret)
defer close(ret)
style := classTypes[s.ctype].style
uitask <- &uimsg{
call: _setWindowLong,
p: []uintptr{
uintptr(s.hwnd),
uintptr(_GWL_STYLE),
uintptr(style | _PBS_MARQUEE),
},
ret: ret,
}
r := <-ret
if r.ret == 0 {
panic(fmt.Errorf("error setting progress bar style to enable/disable marquee (percent %d; style 0x%X): %v", percent, style, r.err))
}
wparam := uintptr(_WPARAM(_FALSE))
if percent == -1 {
wparam = uintptr(_WPARAM(_TRUE))
}
uitask <- &uimsg{
call: _sendMessage,
p: []uintptr{
uintptr(s.hwnd),
uintptr(_PBM_SETMARQUEE),
wparam,
uintptr(0),
},
ret: ret,
}
<-ret
if percent == -1 {
return
}
uitask <- &uimsg{
call: _setWindowLong,
p: []uintptr{
uintptr(s.hwnd),
uintptr(_GWL_STYLE),
uintptr(style),
},
ret: ret,
}
r = <-ret
if r.ret == 0 {
panic(fmt.Errorf("error setting progress bar style to set a percent (percent %d; style 0x%X): %v", percent, style, r.err))
}
uitask <- &uimsg{
call: _sendMessage,
p: []uintptr{
uintptr(s.hwnd),
uintptr(_PBM_SETPOS),
uintptr(_WPARAM(percent)),
uintptr(0),
},
ret: ret,
}
<-ret
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment