Click here to Skip to main content
13,147,182 members (23,101 online)
Click here to Skip to main content
Add your own
alternative version


78 bookmarked
Posted 6 May 2003

How to implement a scrollable child dialog

, 11 May 2003
Rate this:
Please Sign up or sign in to vote.
How to implement a scrollable child dialog

Sample Image - ScrollableChildDialog.jpg


Many times it happened to me (and I hope to you too!) the need for a kind of child dialog, to use as a control inside a more bigger dialog or window or view etc. Filling this child dialog of controls is easy. Set the size of it to fit inside the parent window is not so easy. So, here is the scrollable child dialog, which i found veeeeery useful in my applications.

The code

The code is really simple and is strongly based on the MSDN article HOWTO: Create a Resizable Dialog Box with Scroll Bars (Q262954). I simply created the scrollable dialog template choosing the WS_CHILD and WS_VSCROLL styles and used class wizard to add WM_SIZE, WM_MOUSEWHEEL and WM_VSCROLL messages. To use the code in your project follow these steps:

  1. Add dlgscrollable.h and dlgscrollable.cpp to your project
  2. Create your own dialog resource template and replace the resource identifier in the header file
  3. In the parent window, add a member variable like CDlgScrollable* m_pdlgScrollable and in the OnInitDialog function, create the new CDlgScrollable object.
  4. In the parent dialog resource template, you can use a static as a placeholder to calc the rectangle of my scrollable child control.
  5. You can easily change the "hand" cursors, loading different resources as needed

It's obviously really simple add support for horizontal scroll, it's symmetric and I didn't really need that... :P

And so...

That's all! I'm sorry for my bad English (I'm Italian), this is my first article. Hope not my last one! Thanx to DD and GM for their suggestions and comments, this is the last version of the code, or at least the last version for the next two months! Have fun!


This article, along with any associated source code and files, is licensed under A Public Domain dedication


About the Author

Massimiliano Conte
Software Developer (Senior) Selex ES
Italy Italy
Hi Smile | :)
I was born in 1970 (Augusta - Italy).
I live in Taranto - Italy.
I work in Taranto - Italy.
I like computer science!!!
That's all!

You may also be interested in...

Comments and Discussions

QuestionLicense? Pin
Member 10018999-Apr-15 8:11
memberMember 10018999-Apr-15 8:11 
AnswerRe: License? Pin
Massimiliano Conte22-Oct-15 22:13
memberMassimiliano Conte22-Oct-15 22:13 
GeneralExplanation of some magic numbers Pin
Bati92-Dec-08 10:50
memberBati92-Dec-08 10:50 
GeneralRe: Explanation of some magic numbers Pin
Massimiliano Conte2-Dec-08 20:57
memberMassimiliano Conte2-Dec-08 20:57 
QuestionEvent handling in the parent Dialog? Pin
Seife13-Sep-07 3:59
memberSeife13-Sep-07 3:59 
Questionpb when using your code !!! [modified] Pin
aabdoos15-Dec-06 1:43
memberaabdoos15-Dec-06 1:43 
QuestionIDC_PLACEHOLDER what's it? Pin
tlbf10-Nov-06 2:16
membertlbf10-Nov-06 2:16 
AnswerRe: IDC_PLACEHOLDER what's it? Pin
JonathanLivingstone10-Nov-06 3:02
memberJonathanLivingstone10-Nov-06 3:02 
You have to add an invisible static control in your "parent" dialog, a placeholder to calc the child size and position, then set the resource id of that control as IDC_PLACEHOLDER.
bye! Smile | :)
QuestionCenter dialog on startup? Pin
rturrentine25-May-05 6:03
memberrturrentine25-May-05 6:03 
GeneralSome notes and adjustements Pin
Davide Zaccanti27-Mar-05 20:32
memberDavide Zaccanti27-Mar-05 20:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170915.1 | Last Updated 12 May 2003
Article Copyright 2003 by Massimiliano Conte
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid