Click here to Skip to main content
Click here to Skip to main content

How to implement a scrollable child dialog

By , 11 May 2003
 

Sample Image - ScrollableChildDialog.jpg

Introduction

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!

License

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 SI
Italy Italy
Member
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!

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralExplanation of some magic numbersmemberBati92 Dec '08 - 10:50 
GeneralRe: Explanation of some magic numbersmemberMassimiliano Conte2 Dec '08 - 20:57 
QuestionEvent handling in the parent Dialog?memberSeife13 Sep '07 - 3:59 
Questionpb when using your code !!! [modified]memberaabdoos15 Dec '06 - 1:43 
QuestionIDC_PLACEHOLDER what's it?membertlbf10 Nov '06 - 2:16 
AnswerRe: IDC_PLACEHOLDER what's it?memberJonathanLivingstone10 Nov '06 - 3:02 
QuestionCenter dialog on startup?memberrturrentine25 May '05 - 6:03 
GeneralSome notes and adjustementsmemberDavide Zaccanti27 Mar '05 - 20:32 
GeneralGreat but...memberpgiustinoni28 Feb '05 - 14:01 
Have you ever tried this class in a MDI environment?
It seems all working in debug mode, but in release mode when you try to communicate to the parent, it result in a CRASH of the application...
I have a MDI form that call a dialog in which I putted this class... I'm not able to communicate to any of the MDI window, nor the main wnd. I tried with SendMessage(), PostMessage(), RegisterWindowMessage()... NO WAY TO COMMUNICATE WITHOUT A CRASH.
I'm very surprised, in particular 'cause there is no problem in debug mode..

GeneralResizing original dialogmemberandrew_lowry15 Apr '04 - 3:50 
Generalfix for embedded visual c++ 4.0memberSpellcaster14 Mar '04 - 7:42 
QuestionHow can I implement this for a Dialog and not a for a child of a Dialog?memberDanYELL8 Feb '04 - 7:54 
AnswerRe: How can I implement this for a Dialog and not a for a child of a Dialog?memberJonathanLivingstone8 Feb '04 - 22:46 
QuestionHow can I get this to work with a CFormView?memberDanYELL6 Feb '04 - 6:05 
GeneralTab Key and Scroll Dialog boxsussAnonymous28 Jan '04 - 22:10 
Generalscrollbar position on startmemberteamghost16 Oct '03 - 1:47 
Generalit helped memembersanskypotov3 Sep '03 - 0:01 
GeneralRe: it helped mememberNiFF21 Jun '05 - 6:07 
GeneralExact same problem as Keithmemberyklam15 Jul '03 - 5:00 
GeneralSolution Foundmemberyklam21 Jul '03 - 4:50 
QuestionHow to use this powerful class in embedded visual c++ 3.0?memberkeithse26 Jun '03 - 11:38 
AnswerRe: How to use this powerful class in embedded visual c++ 3.0?memberKaiserle21 Jul '03 - 3:44 
GeneralMousewheel does not work.memberBrian van der Beek22 May '03 - 5:08 
GeneralRe: Mousewheel does not work.memberJonathanLivingstone23 May '03 - 1:40 
GeneralRe: Mousewheel does not work.membersonu_22413 Aug '07 - 1:50 

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

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