5,691,626 members and growing! (13,071 online)
Email Password   helpLost your password?
Desktop Development » Dialogs and Windows » Dialogs     Intermediate

How to implement a scrollable child dialog

By Massimiliano Conte

How to implement a scrollable child dialog
VC6, VC7, C++Windows, Win2K, WinXP, MFC, VS.NET2002, VS6, Visual Studio, Dev

Posted: 6 May 2003
Updated: 11 May 2003
Views: 121,242
Bookmarked: 40 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
42 votes for this Article.
Popularity: 7.38 Rating: 4.55 out of 5
1 vote, 2.4%
1
2 votes, 4.8%
2
4 votes, 9.5%
3
3 votes, 7.1%
4
32 votes, 76.2%
5

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


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!
Occupation: Software Developer (Senior)
Company: ElsagDatamat
Location: Italy Italy

Other popular Dialogs and Windows articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 30 (Total in Forum: 30) (Refresh)FirstPrevNext
GeneralEvent handling in the parent Dialog?memberSeife4:59 13 Sep '07  
Questionpb when using your code !!! [modified]memberaabdoos2:43 15 Dec '06  
GeneralIDC_PLACEHOLDER what's it?membertlbf3:16 10 Nov '06  
GeneralRe: IDC_PLACEHOLDER what's it?memberJonathanLivingstone4:02 10 Nov '06  
GeneralCenter dialog on startup?memberrturrentine7:03 25 May '05  
GeneralSome notes and adjustementsmemberDavide Zaccanti21:32 27 Mar '05  
GeneralGreat but...memberpgiustinoni15:01 28 Feb '05  
GeneralResizing original dialogmemberandrew_lowry4:50 15 Apr '04  
Generalfix for embedded visual c++ 4.0memberSpellcaster8:42 14 Mar '04  
GeneralHow can I implement this for a Dialog and not a for a child of a Dialog?memberDanYELL8:54 8 Feb '04  
GeneralRe: How can I implement this for a Dialog and not a for a child of a Dialog?memberJonathanLivingstone23:46 8 Feb '04  
GeneralHow can I get this to work with a CFormView?memberDanYELL7:05 6 Feb '04  
GeneralTab Key and Scroll Dialog boxsussAnonymous23:10 28 Jan '04  
Generalscrollbar position on startmemberteamghost2:47 16 Oct '03  
Generalit helped memembersanskypotov1:01 3 Sep '03  
GeneralRe: it helped mememberNiFF7:07 21 Jun '05  
GeneralExact same problem as Keithmemberyklam6:00 15 Jul '03  
GeneralSolution Foundmemberyklam5:50 21 Jul '03  
GeneralHow to use this powerful class in embedded visual c++ 3.0?memberkeithse12:38 26 Jun '03  
GeneralRe: How to use this powerful class in embedded visual c++ 3.0?memberKaiserle4:44 21 Jul '03  
GeneralMousewheel does not work.memberBrian van der Beek6:08 22 May '03  
GeneralRe: Mousewheel does not work.memberJonathanLivingstone2:40 23 May '03  
GeneralRe: Mousewheel does not work.membersonu_2242:50 13 Aug '07  
GeneralJust one more thing...memberIv7:10 7 May '03  
GeneralRe: Just one more thing...memberJonathanLivingstone21:27 7 May '03  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 11 May 2003
Editor: Smitha Vijayan
Copyright 2003 by Massimiliano Conte
Everything else Copyright © CodeProject, 1999-2008
Web13 | Advertise on the Code Project