User forums > Help
simple question enable scroll under wxsmith?
(1/1)
ollydbg:
I admit I'm a wxWidgets beginner. (Maybe, this is a wxWidgets related problem)
Now, I have a project I create a wxFrame based project wizards, then I just add a wxPanel in the frame. Now, I have add many items in the panel. Then, the wxPanel is quite big, so if the wxFrame's size is smaller than the wxPanel, some items were cropped. Are there any option that I can enable the scroll bar on the wxFrame so I can scroll if wxFrame size is smaller? (the problem is the scroll bar is shown, but drag the scroll bar gives nothing)
I have tried some way (enable scroll option in wxFrame) but does not work. It looks like there is an item wxScrollWindow, but I have drag this item in wxsmith, but still now how to enable scroll.
Any ideas?
Thanks.
Jenna:
Do you know the wxWidgets book:
it's free for download from http://www.informit.com/promotions/promotion.aspx?promo=135563 (there are several other interesting and free books on this side).
Direct link: http://www.phptr.com/content/images/0131473816/downloads/0131473816_book.pdf
With wxScrolledWindow, you still need to setup the scrollbars-dimensions, but do not need to create event-handlers for scrolling, as it is needed by other windows.
You can put something like
--- Code: ---ScrolledWindow1->SetScrollbars(10, 10, 100, 100);
--- End code ---
in the "Extra code" section of the wxScrolledWindow (assuming the variable holding the pointer to the scrolled window is called ScrolledWindow1).
You can place all the stuff directly into it, without the need of a wxPanel.
I personally prefer to work with sizers and use the automatically layout capability of wxWidgets.
ollydbg:
--- Quote from: jens on January 04, 2012, 12:11:41 pm ---Do you know the wxWidgets book:
it's free for download from http://www.informit.com/promotions/promotion.aspx?promo=135563 (there are several other interesting and free books on this side).
Direct link: http://www.phptr.com/content/images/0131473816/downloads/0131473816_book.pdf
--- End quote ---
Yes, I have this book(CHM version) when I begin to use wxWidgets three years ago, but I briefly read it :).
Now I see there is a section "container window" in chapter 4 to introduce the wxScrolledWindow, so I will read it right now, Thank you very much for your directions and links.
--- Quote ---With wxScrolledWindow, you still need to setup the scrollbars-dimensions, but do not need to create event-handlers for scrolling, as it is needed by other windows.
You can put something like
--- Code: ---ScrolledWindow1->SetScrollbars(10, 10, 100, 100);
--- End code ---
in the "Extra code" section of the wxScrolledWindow (assuming the variable holding the pointer to the scrolled window is called ScrolledWindow1).
You can place all the stuff directly into it, without the need of a wxPanel.
I personally prefer to work with sizers and use the automatically layout capability of wxWidgets.
--- End quote ---
I will test your code after carefully reading the "containing window" section.
ollydbg:
I found a trick that I can quickly change the type wxPanel to wxScrolledWindow(Leave every items unchanged), see the screen shot:
Then add the extra code
--- Code: ---Panel1->SetScrollbars(10, 10, 100, 100);
--- End code ---
Now, my original "wxPanel" becomes to "wxScrolledWindow" which has scrolled bars work OK.
Great thanks to jens!!!
Navigation
[0] Message Index
Go to full version