![]() |
|
QA: How do I scroll the contents of a dialog?
By Joao Paulo Figueira, September 22, 2003.
QuestionI have a dialog that does not fit on the screen. How can I scroll its contents? AnswerThe short answer is no: dialogs were not meant to be scrolled. However, we can achieve a similar effect using a dialog, a scroller window and a property page. The principles are the same as the ones presented by Daniel Strigl's article QA: How can I create a wizard style dialog?.
ImplementationThis solution uses three classes: CScrollDialog, CPageContainer and a CPropertyPage-derived class. This one is created like a normal property page without border. You can add all the controls you want (screen size is not a limitation). The property page is managed (scrolled) by an instance of CPageContainer. This class serves the only purpose of containing the property page and managing the scrolling. It also manages the data updating when the user clicks OK on the containig dialog. Finally, the CScrollDialog is the class that implements the containing dialog. In the sample application, this dialog contains a property sheet-like header and the child dialog (contained in an instance of CPageContainer), occupies the rest of the user area. In a nutshell: CScrollDialog contains CPageContainer that contains a CPropertyPage. Using the Scrollable DialogUsing the dialog is simple. You declare an instance of CScrollDialog and another of the CPropertyPage-derived class. Set the dialog variables, use the SetPage() method, and you are set:
And that's it. SampleYou can download a sample here - ScrollDlgDemo.zip (150K). Related resources:
DiscussDiscuss this article. Here you can write your comments and read comments of other developers. |
|||||||||||||||||||||