Scroll to an arbitrary position

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
bluesnowball18
Earned a small fee
Earned a small fee
Posts: 13
Joined: Thu Apr 22, 2021 9:23 am

Scroll to an arbitrary position

Post by bluesnowball18 »

I have wxScrolled container with the scroll rate greater than 1.

My question is, how can I set wxScrolled viewport starting point to an arbitrary position in pixels, not in scroll units? wxWindow::ScrollWindow doesn't work with wxScrolled, or maybe I'm using it wrong:

Code: Select all

Canvas::Canvas(wxWindow *parent)
        : wxScrolledCanvas(parent, wxID_ANY)
{
        SetScrollRate(4, 4);
        SetVirtualSize(100, 4000);

        ScrollWindow(0, 5);

        printf("%d\n", GetViewStart().y); // always returns 0
}
Post Reply