diff options
| author | Pietro Gagliardi <[email protected]> | 2014-03-12 18:53:57 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-03-12 18:53:57 -0400 |
| commit | 4b0315131aa3b29b453ba671bd9c7be03190746c (patch) | |
| tree | e2ba2d03241dd163788a4edc3b442963d27f1d9e /sysdata_windows.go | |
| parent | 6ee8d96a6e8c1e95b8ca2ab19fcc6a3a856d50c8 (diff) | |
Added indeterminate ProgressBar code on Windows and fixed up a few other things along the way.
Diffstat (limited to 'sysdata_windows.go')
| -rw-r--r-- | sysdata_windows.go | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/sysdata_windows.go b/sysdata_windows.go index fbba1fd..5ef9209 100644 --- a/sysdata_windows.go +++ b/sysdata_windows.go @@ -15,6 +15,7 @@ type sysData struct { children map[_HMENU]*sysData nextChildID _HMENU childrenLock sync.Mutex + isMarquee bool // for sysData.setProgress() } type classData struct { @@ -514,9 +515,71 @@ func (s *sysData) delete(index int) { } } +func (s *sysData) setIndeterminate() { + ret := make(chan uiret) + defer close(ret) + uitask <- &uimsg{ + call: _setWindowLong, + p: []uintptr{ + uintptr(s.hwnd), + uintptr(_GWL_STYLE), + uintptr(classTypes[s.ctype].style | _PBS_MARQUEE), + }, + ret: ret, + } + r := <-ret + if r.ret == 0 { + panic(fmt.Errorf("error setting progress bar style to enter indeterminate mode: %v", r.err)) + } + uitask <- &uimsg{ + call: _sendMessage, + p: []uintptr{ + uintptr(s.hwnd), + uintptr(_PBM_SETMARQUEE), + uintptr(_WPARAM(_TRUE)), + uintptr(0), + }, + ret: ret, + } + <-ret + s.isMarquee = true +} + func (s *sysData) setProgress(percent int) { + if percent == -1 { + s.setIndeterminate() + return + } ret := make(chan uiret) defer close(ret) + if s.isMarquee { + // turn off marquee before switching back + uitask <- &uimsg{ + call: _sendMessage, + p: []uintptr{ + uintptr(s.hwnd), + uintptr(_PBM_SETMARQUEE), + uintptr(_WPARAM(_FALSE)), + uintptr(0), + }, + ret: ret, + } + <-ret + uitask <- &uimsg{ + call: _setWindowLong, + p: []uintptr{ + uintptr(s.hwnd), + uintptr(_GWL_STYLE), + uintptr(classTypes[s.ctype].style), + }, + ret: ret, + } + r := <-ret + if r.ret == 0 { + panic(fmt.Errorf("error setting progress bar style to leave indeterminate mode (percent %d): %v", percent, r.err)) + } + s.isMarquee = false + } uitask <- &uimsg{ call: _sendMessage, p: []uintptr{ |
