I am writing a Win32 application (C++) using DirectComposition and DirectManipulation. I have sucessfully created a my own Scroll View control by setting viewport and content visuals.
It all works nicely, yet I cannot seem to figure out how to programmatically move the content in the viewport. I would like to create ScrollTo
behavior where you can bring some content into view.
I've been fiddling around with SyncContentTransform
but it doesn’t seem to do anything. Do I need to call some other function to commit the sync? Documentation and examples barely exist, I am hoping someone can help me out.
I have figured this out myself. You should use the
ZoomToRect
method on the viewport object to scroll the content programmatically. I was ignoring this method because it stated "Zoom". Doh.Here is a link to the function: https://learn.microsoft.com/en-us/windows/win32/api/directmanipulation/nf-directmanipulation-idirectmanipulationviewport-zoomtorect