diff options
| author | Pietro Gagliardi <[email protected]> | 2014-06-07 23:27:38 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-06-07 23:27:38 -0400 |
| commit | ef3adffd5476baae8ac805940489455de12d5461 (patch) | |
| tree | 7dd2b19dc4edcea102d5550187da23ee6dac5d3b /sysdata_windows.go | |
| parent | d9a8cf07b90c7931115b9386f4bdab36fbacfc0e (diff) | |
Fixed the Windows 7 progressbar animation dumbness.
Diffstat (limited to 'sysdata_windows.go')
| -rw-r--r-- | sysdata_windows.go | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/sysdata_windows.go b/sysdata_windows.go index 8d858a1..12100f2 100644 --- a/sysdata_windows.go +++ b/sysdata_windows.go @@ -606,17 +606,32 @@ func (s *sysData) setProgress(percent int) { } s.isMarquee = false } - uitask <- &uimsg{ - call: _sendMessage, - p: []uintptr{ - uintptr(s.hwnd), - uintptr(_PBM_SETPOS), - uintptr(_WPARAM(percent)), - uintptr(0), - }, - ret: ret, + send := func(msg uintptr, n int, l _LPARAM) { + uitask <- &uimsg{ + call: _sendMessage, + p: []uintptr{ + uintptr(s.hwnd), + msg, + uintptr(_WPARAM(n)), + uintptr(l), + }, + ret: ret, + } + <-ret + } + // Windows 7 has a non-disableable slowly-animating progress bar increment + // there isn't one for decrement, so we'll work around by going one higher and then lower again + // for the case where percent == 100, we need to increase the range temporarily + // this kind of thing is why I want to move away from uimsg and toward having uitask take func()s like on the other platforms + // sources: http://social.msdn.microsoft.com/Forums/en-US/61350dc7-6584-4c4e-91b0-69d642c03dae/progressbar-disable-smooth-animation http://stackoverflow.com/questions/2217688/windows-7-aero-theme-progress-bar-bug http://discuss.joelonsoftware.com/default.asp?dotnet.12.600456.2 http://stackoverflow.com/questions/22469876/progressbar-lag-when-setting-position-with-pbm-setpos http://stackoverflow.com/questions/6128287/tprogressbar-never-fills-up-all-the-way-seems-to-be-updating-too-fast + if percent == 100 { + send(_PBM_SETRANGE32, 0, 101) + } + send(_PBM_SETPOS, percent + 1, 0) + send(_PBM_SETPOS, percent, 0) + if percent == 100 { + send(_PBM_SETRANGE32, 0, 100) } - <-ret } func (s *sysData) len() int { |
