Click here to Skip to main content
11,412,833 members (73,038 online)
Click here to Skip to main content

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


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!

Comments and Discussions

QuestionLicense? Pin
Member 1001899 at 9-Apr-15 9:11
memberMember 10018999-Apr-15 9:11 
GeneralExplanation of some magic numbers Pin
Bati9 at 2-Dec-08 11:50
memberBati92-Dec-08 11:50 
GeneralRe: Explanation of some magic numbers Pin
Massimiliano Conte at 2-Dec-08 21:57
memberMassimiliano Conte2-Dec-08 21:57 
QuestionEvent handling in the parent Dialog? Pin
Seife at 13-Sep-07 4:59
memberSeife13-Sep-07 4:59 
Questionpb when using your code !!! [modified] Pin
aabdoos at 15-Dec-06 2:43
memberaabdoos15-Dec-06 2:43 
QuestionIDC_PLACEHOLDER what's it? Pin
tlbf at 10-Nov-06 3:16
membertlbf10-Nov-06 3:16 
AnswerRe: IDC_PLACEHOLDER what's it? Pin
JonathanLivingstone at 10-Nov-06 4:02
memberJonathanLivingstone10-Nov-06 4:02 
QuestionCenter dialog on startup? Pin
rturrentine at 25-May-05 7:03
memberrturrentine25-May-05 7:03 
GeneralSome notes and adjustements Pin
Davide Zaccanti at 27-Mar-05 21:32
memberDavide Zaccanti27-Mar-05 21:32 
GeneralGreat but... Pin
pgiustinoni at 28-Feb-05 15:01
memberpgiustinoni28-Feb-05 15:01 
GeneralResizing original dialog Pin
andrew_lowry at 15-Apr-04 4:50
memberandrew_lowry15-Apr-04 4:50 
Generalfix for embedded visual c++ 4.0 Pin
Spellcaster at 14-Mar-04 8:42
memberSpellcaster14-Mar-04 8:42 
QuestionHow can I implement this for a Dialog and not a for a child of a Dialog? Pin
DanYELL at 8-Feb-04 8:54
memberDanYELL8-Feb-04 8:54 
AnswerRe: How can I implement this for a Dialog and not a for a child of a Dialog? Pin
JonathanLivingstone at 8-Feb-04 23:46
memberJonathanLivingstone8-Feb-04 23:46 
QuestionHow can I get this to work with a CFormView? Pin
DanYELL at 6-Feb-04 7:05
memberDanYELL6-Feb-04 7:05 
GeneralTab Key and Scroll Dialog box Pin
Anonymous at 28-Jan-04 23:10
sussAnonymous28-Jan-04 23:10 
Generalscrollbar position on start Pin
teamghost at 16-Oct-03 2:47
memberteamghost16-Oct-03 2:47 
Generalit helped me Pin
sanskypotov at 3-Sep-03 1:01
membersanskypotov3-Sep-03 1:01 
GeneralRe: it helped me Pin
NiFF at 21-Jun-05 7:07
memberNiFF21-Jun-05 7:07 
GeneralExact same problem as Keith Pin
yklam at 15-Jul-03 6:00
memberyklam15-Jul-03 6:00 
GeneralSolution Found Pin
yklam at 21-Jul-03 5:50
memberyklam21-Jul-03 5:50 
QuestionHow to use this powerful class in embedded visual c++ 3.0? Pin
keithse at 26-Jun-03 12:38
memberkeithse26-Jun-03 12:38 
AnswerRe: How to use this powerful class in embedded visual c++ 3.0? Pin
Kaiserle at 21-Jul-03 4:44
memberKaiserle21-Jul-03 4:44 
GeneralMousewheel does not work. Pin
Brian van der Beek at 22-May-03 6:08
memberBrian van der Beek22-May-03 6:08 
GeneralRe: Mousewheel does not work. Pin
JonathanLivingstone at 23-May-03 2:40
memberJonathanLivingstone23-May-03 2:40 

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

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

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