Code::Blocks Forums

User forums => Help => Topic started by: ollydbg on January 04, 2012, 09:28:16 am

Title: simple question enable scroll under wxsmith?
Post by: ollydbg on January 04, 2012, 09:28:16 am
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.
Title: Re: simple question enable scroll under wxsmith?
Post by: Jenna 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 (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 (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);
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.
Title: Re: simple question enable scroll under wxsmith?
Post by: ollydbg on January 04, 2012, 03:02:47 pm
Do you know the wxWidgets book:
it's free for download from http://www.informit.com/promotions/promotion.aspx?promo=135563 (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 (http://www.phptr.com/content/images/0131473816/downloads/0131473816_book.pdf)
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);
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.
I will test your code after carefully reading the "containing window" section.
Title: Re: simple question enable scroll under wxsmith?
Post by: ollydbg on January 04, 2012, 03:40:41 pm
I found a trick that I can quickly change the type wxPanel to wxScrolledWindow(Leave every items unchanged), see the screen shot:
(http://i683.photobucket.com/albums/vv194/ollydbg_cb/2012-01-04223844.png)
Then add the extra code
Code
Panel1->SetScrollbars(10, 10, 100, 100);
Now, my original "wxPanel" becomes to "wxScrolledWindow" which has scrolled bars work OK.
Great thanks to jens!!!