one pair of scollbars in parent window for all child controls Topic is solved

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
Ronald
Earned some good credits
Earned some good credits
Posts: 104
Joined: Mon Mar 05, 2018 4:17 am

one pair of scollbars in parent window for all child controls

Post by Ronald » Sun Sep 01, 2019 4:46 pm

Untitled.png
Untitled.png (10.82 KiB) Viewed 85 times
In the top side image, two wxGrid's (in wxBoxSizer) in wxPanel, each got horizontal and vertical scrollbars.
When wxGrid's becomes more, too much scrollbars is not good.

How to only use scrollbars in the parent window, as in the bottom side image?

Even harder,
is it easy to show a horizontal scrollbar and no vertical scrollbar for each wxGrid while a vertical scrollbar and no horizontal scrollbar for the parent window?
If this is not easy, ignore it.

User avatar
doublemax
Moderator
Moderator
Posts: 13985
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: one pair of scollbars in parent window for all child controls

Post by doublemax » Sun Sep 01, 2019 9:14 pm

In the top side image, two wxGrid's (in wxBoxSizer) in wxPanel
Use wxScrolledWindow instead of wxPanel and make the virtual area big enough so that the grid doesn't show scrollbars.
Use the source, Luke!

Ronald
Earned some good credits
Earned some good credits
Posts: 104
Joined: Mon Mar 05, 2018 4:17 am

Re: one pair of scollbars in parent window for all child controls

Post by Ronald » Mon Sep 02, 2019 2:30 pm

doublemax wrote:
Sun Sep 01, 2019 9:14 pm
Use wxScrolledWindow instead of wxPanel and make the virtual area big enough so that the grid doesn't show scrollbars.
Derived from wxScrolledWindow, with style

Code: Select all

wxHSCROLL | wxVSCROLL
After add some child window, called

Code: Select all

FitInside()
Check virtual size by

Code: Select all

GetVirtualSize
The returned size is ok and bigger than my display, but no scrollbars appear.
The wxScrolledWindow derived class is used as page for wxAuiNotebook.
What's the problem?

Thanks

User avatar
doublemax
Moderator
Moderator
Posts: 13985
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: one pair of scollbars in parent window for all child controls

Post by doublemax » Mon Sep 02, 2019 3:31 pm

Derived from wxScrolledWindow,
Why? Normal wxScrolledWindow should be enough.

Code: Select all

wxHSCROLL | wxVSCROLL
Not necessary.
but no scrollbars appear.
Add a call to SetScrollRate().
https://docs.wxwidgets.org/trunk/classw ... 06a44a9401
Use the source, Luke!

Ronald
Earned some good credits
Earned some good credits
Posts: 104
Joined: Mon Mar 05, 2018 4:17 am

Re: one pair of scollbars in parent window for all child controls

Post by Ronald » Mon Sep 02, 2019 4:59 pm

doublemax wrote:
Mon Sep 02, 2019 3:31 pm
Why? Normal wxScrolledWindow should be enough.
Need to load data for each wxGrid, and create those wxGrid's dynamically.
doublemax wrote:
Mon Sep 02, 2019 3:31 pm

Code: Select all

wxHSCROLL | wxVSCROLL
Not necessary.
Yes.
doublemax wrote:
Mon Sep 02, 2019 3:31 pm
Add a call to SetScrollRate().
A little tricky, hard to find the solution, a default/auto-generated value is preferred.
It works better than I expected, hscrollbar and vscrollbar are decoupled, each shows as needed, very nice.

Thanks very much

Post Reply