summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-06-07 23:27:38 -0400
committerPietro Gagliardi <[email protected]>2014-06-07 23:27:38 -0400
commitef3adffd5476baae8ac805940489455de12d5461 (patch)
tree7dd2b19dc4edcea102d5550187da23ee6dac5d3b
parentd9a8cf07b90c7931115b9386f4bdab36fbacfc0e (diff)
Fixed the Windows 7 progressbar animation dumbness.
-rw-r--r--sysdata_windows.go35
-rw-r--r--todo.md2
-rw-r--r--zconstants_windows_386.go1
-rw-r--r--zconstants_windows_amd64.go1
4 files changed, 27 insertions, 12 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 {
diff --git a/todo.md b/todo.md
index 73b86f1..676474a 100644
--- a/todo.md
+++ b/todo.md
@@ -9,8 +9,6 @@ WINDOWS:
- the windows build appears to be unstable:
- 64-bit crashes in malloc in wine with heap corruption warnings aplenty during DLL loading; in windows 7 it works fine
- redrawing controls after a window resize on Windows does not work properly
-- on windows 7, progress bars seem to animate from 0 -> pos when you turn off marquee mode and set pos; see if that's documented or if I'm doing something wrong
- - intentional: 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 - these links have workarounds but blah; more proof that progressbars were programmatically intended to be incremented in steps
- check all uses of RECT.right/.bottom in Windows that don't have an accompanying -RECT.left/.top to make sure they're correct
- when adding IsDialogMessage() find out if that make sthe area in the area bounds test automatically focused
diff --git a/zconstants_windows_386.go b/zconstants_windows_386.go
index 51bdbcc..eb24354 100644
--- a/zconstants_windows_386.go
+++ b/zconstants_windows_386.go
@@ -61,6 +61,7 @@ const _MK_XBUTTON1 = 32
const _MK_XBUTTON2 = 64
const _PBM_SETMARQUEE = 1034
const _PBM_SETPOS = 1026
+const _PBM_SETRANGE32 = 1030
const _PBS_MARQUEE = 8
const _PBS_SMOOTH = 1
const _SB_HORZ = 0
diff --git a/zconstants_windows_amd64.go b/zconstants_windows_amd64.go
index 0eb90f0..95c07a7 100644
--- a/zconstants_windows_amd64.go
+++ b/zconstants_windows_amd64.go
@@ -61,6 +61,7 @@ const _MK_XBUTTON1 = 32
const _MK_XBUTTON2 = 64
const _PBM_SETMARQUEE = 1034
const _PBM_SETPOS = 1026
+const _PBM_SETRANGE32 = 1030
const _PBS_MARQUEE = 8
const _PBS_SMOOTH = 1
const _SB_HORZ = 0