summaryrefslogtreecommitdiff
path: root/area_windows.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-03-25 08:23:31 -0400
committerPietro Gagliardi <[email protected]>2014-03-25 08:23:31 -0400
commit13370c22d314f6e8b7d87e692e392f3606388703 (patch)
treec5f24ad716ebf598a1fec0244237cba41ba4c576 /area_windows.go
parent136f2262fdf20ffe092567a3f7130668f4f1c7a0 (diff)
Added the actual scrolling to Windows Areas. Now to just adjust the cliprect properly...
Diffstat (limited to 'area_windows.go')
-rw-r--r--area_windows.go25
1 files changed, 24 insertions, 1 deletions
diff --git a/area_windows.go b/area_windows.go
index 33692fb..4b4eedc 100644
--- a/area_windows.go
+++ b/area_windows.go
@@ -208,7 +208,30 @@ func scrollArea(hwnd _HWND, wparam _WPARAM, which uintptr) {
return
}
- // TODO scroll
+ delta := -(newpos - si.nPos) // negative because ScrollWindowEx() scrolls in the opposite direction
+ dx := delta
+ dy := int32(0)
+ if which == uintptr(_SB_VERT) {
+ dx = int32(0)
+ dy = delta
+ }
+ r1, _, err = _scrollWindowEx.Call(
+ uintptr(hwnd),
+ uintptr(dx),
+ uintptr(dy),
+ uintptr(0), // these four change what is scrolled and record info about the scroll; we're scrolling the whole client area and don't care about the returned information here
+ uintptr(0),
+ uintptr(0),
+ uintptr(0),
+ // TODO also SW_ERASE? or will the GetUpdateRect() call handle it?
+ uintptr(_SW_INVALIDATE)) // mark the remaining rect as needing redraw...
+ if r1 == _ERROR { // failure
+ panic(fmt.Errorf("error scrolling Area: %v", err))
+ }
+ r1, _, err = _updateWindow.Call(uintptr(hwnd)) // ...and redraw it
+ if r1 == 0 { // failure
+ panic(fmt.Errorf("error updating Area after scrolling: %v", err))
+ }
// we actually have to commit the change back to the scrollbar; otherwise the scroll position will merely reset itself
si.cbSize = uint32(unsafe.Sizeof(si))