Click here to Skip to main content
12,887,536 members (26,785 online)
Click here to Skip to main content
Add your own
alternative version


77 bookmarked
Posted 6 May 2003

How to implement a scrollable child dialog

, 11 May 2003 Public Domain
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

Generalit helped me Pin
sanskypotov3-Sep-03 0:01
membersanskypotov3-Sep-03 0:01 
GeneralRe: it helped me Pin
NiFF21-Jun-05 6:07
memberNiFF21-Jun-05 6:07 
GeneralExact same problem as Keith Pin
yklam15-Jul-03 5:00
memberyklam15-Jul-03 5:00 
GeneralSolution Found Pin
yklam21-Jul-03 4:50
memberyklam21-Jul-03 4:50 
QuestionHow to use this powerful class in embedded visual c++ 3.0? Pin
keithse26-Jun-03 11:38
memberkeithse26-Jun-03 11:38 
Hi John,
I really think this class is valuable, however I failed to port this code to embedded visual c++ 3.0. First of all, it give me error when compiling, saying there is no OnMouseWheel command, so I comment out this definition and implementation. Then, when I start my sample app in PocketPC 2002 emulator, i can see my child dialog in place, but it doesn't respond to the scrollbar.

Can you help?

Best Regards,
AnswerRe: How to use this powerful class in embedded visual c++ 3.0? Pin
Kaiserle21-Jul-03 3:44
memberKaiserle21-Jul-03 3:44 
GeneralMousewheel does not work. Pin
Brian van der Beek22-May-03 5:08
memberBrian van der Beek22-May-03 5:08 
GeneralRe: Mousewheel does not work. Pin
JonathanLivingstone23-May-03 1:40
memberJonathanLivingstone23-May-03 1:40 
GeneralRe: Mousewheel does not work. Pin
sonu_22413-Aug-07 1:50
membersonu_22413-Aug-07 1:50 
GeneralRe: Mousewheel does not work. Pin
adzm5-Feb-10 9:43
memberadzm5-Feb-10 9:43 
GeneralJust one more thing... Pin
Iv7-May-03 6:10
memberIv7-May-03 6:10 
GeneralRe: Just one more thing... Pin
JonathanLivingstone7-May-03 20:27
memberJonathanLivingstone7-May-03 20:27 
GeneralAlternatives to a scrollbar... Pin
Merrion7-May-03 0:52
memberMerrion7-May-03 0:52 
GeneralQuite incredible indeed... Pin
.S.Rod.7-May-03 0:42
member.S.Rod.7-May-03 0:42 
GeneralRe: Quite incredible indeed... Pin
Anonymous8-May-03 5:33
sussAnonymous8-May-03 5:33 
GeneralRe: Quite incredible indeed... Pin
Anonymous8-May-03 7:10
sussAnonymous8-May-03 7:10 
GeneralRe: Quite incredible indeed... Pin
Anonymous8-May-03 11:30
sussAnonymous8-May-03 11:30 

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
Web02 | 2.8.170424.1 | Last Updated 12 May 2003
Article Copyright 2003 by Massimiliano Conte
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid