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 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_VSCROLL styles and used class wizard to add
WM_VSCROLL messages. To use the code in your project follow these steps:
- Add dlgscrollable.h and dlgscrollable.cpp to your project
- Create your own dialog resource template and replace the resource identifier in the header file
- In the parent window, add a member variable like
CDlgScrollable* m_pdlgScrollable and in the
OnInitDialog function, create the new
- In the parent dialog resource template, you can use a static as a placeholder to calc the rectangle of my scrollable child control.
- 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
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!