蝙蝠侠小丑身世:How to implement a scrollable child dialog

来源:百度文库 编辑:九乡新闻网 时间:2024/04/30 00:21:19

How to implement a scrollable child dialog

By Massimiliano Conte |12 May 2003VC6VC7Win2KWinXPMFCDevIntermediateHow to implement a scrollable child dialog See Also
  • More like this
  • More by this author
Print Article Twitter Digg Facebook Del.icio.us Reddit Stumbleupon Newsvine Technorati Mr. Wong Yahoo! Google Windows Live Send as Email Add to your CodeProject bookmarksDiscuss this article33 Article Browse Code Stats Revisions   4.59 (46 votes)
1
2
3
4
5 Sponsored LinksIs your email address OK?You are signed up for our newsletters but your email address is either unconfirmed, or has notbeen reconfirmed in a long time. Please clickhere to have aconfirmation email sent so we can confirm your email address and start sending you newslettersagain. Alternatively, you canupdate your subscriptions.
  • Download demo project - 113 Kb

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