A Scrollable Dialog Class (CScrollDialog) | CodeGuru

A Scrollable Dialog Class (CScrollDialog)

Environment: VC6 SP4, NT4 SP3, Win98 MFC’s CDialog class is a powerful and flexible class but it has its shortcomings. If we wish to allow the user to resize the dialog and still retain access to all controls within the dialog, then we must either resize/displace the controls within the dialog, or implement any scrolling […]

Written By
CodeGuru Staff
CodeGuru Staff
Jul 3, 1999
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Environment: VC6 SP4, NT4 SP3, Win98

MFC’s CDialog class is a powerful and flexible class but it has its shortcomings.
If we wish to allow the user to resize the dialog and still retain access to all controls
within the dialog, then we must either resize/displace the controls within the dialog,
or implement any scrolling functionality ourselves.

There are already a good number of articles in CodeGuru which address the first option.
This article essentially presents a solution to the second option, the scrollable dialog option.
The class presented here is intended to serve as a starting point for those of you who should ever
need to implement scrollability in a dialog; it can be used without modification, or it can
be tailored to your needs.

To implement a CScrollDialog, simply do the following:

  1. Derive your dialog from CScrollDialog rather than from CDialog.
  2. Add the header definition at the top of your dialog’s header file (ie. #include “ScrollDialog.h”)
  3. Size your dialog template in the resource editor to its ideal dimensions.

That’s it! Upon creation, the ScrollDialog stores its initial dimensions for later reference.
Anything smaller than these will enable the corresponding scrollbar(s).

The code was written with MFC version 4.22, and compiles cleanly with Warning level 4.
Unicode compatibility is unknown.

Last but not least, I must mention that the window gripper implementation was drawn
from code snippets found in the CodeGuru site. Enjoy.

Downloads

Download demo project – 20 KB

Download source – 4 KB

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.