Click here to Skip to main content
12,894,708 members (63,072 online)
Click here to Skip to main content
Add your own
alternative version


38 bookmarked
Posted 1 Apr 2003

Scrollable PropertyPage

, 1 Apr 2003
Rate this:
Please Sign up or sign in to vote.
A scrollable property page that resizes the property page instead of the property sheet.


Here is a simple idea which brings a mole of relief to those who are uncomfortable with property pages. This trick which I used will allow you to make scrollable property pages within a property sheet. So now forget the worry of using too many controls within a property page and yet keeping them aligned. The simple idea it uses is changing the size of the property page dialog when it is Initialized.

Apart from that i have also given the code for setting up scroll bars in the code dynamically.


When I started working with VC++ I had a dilemma with using tab controls and property pages and its pros and cons. Later when I used property pages I found myself struck up in a lurch. My application had lot of controls within a property page dialog, but not enough space for them. I searched a lot for making a property page scrollable but could not find one. Later I came up with a simple solution which I have presented here.

The Main Chunk

I will refer to the code taking my demo project as reference. The demo project is a dialog-based application. There are 2 property pages: 1) small property page and 2) sarge property page. A large amount of controls are added to large property page. It looks like this :

Now open the resource file of the application into a text editor. Change the width and height of larger property page (IDD_PROPPAGE_LARGE) to same as that of small property page (IDD_PROPPAGE_SMALL). Finally, the large property page dialog will look like this in your VC++ editor.

Now When this Large property page dialog is initialized set the size of the larger property page such that it covers all the required controls. Get the size of the rectangle covering the property page and multiply it to the x variable. This x variable should be such that all the controls in your property page are visible.

BOOL CProppageLarge::OnInitDialog() 
    // Initialize the Member variable containing Vertical Scrolling Position
    m_nVscrollPos = 0;

    // Get the initial dimensions of the dialog and use it in
    // setting Scroll Position

    ////////////// /HERE IS THE TRICK ////////////////////////    
    //Increase the height of Dialog at Runtime        
    // Here you can use the (x) multiplier as per your requirement by
    // trial and rrror
    m_ClientRect.bottom *= 3; 

    //// SETTING UP A VERTICAL SCROLL BAR ////////////////////    
    //Initialize the VerticalScrollbar

    //Setup The Vertical Scrollbar

    return TRUE;  // return TRUE unless you set the focus to a control

Now when the larger property page is scrolled it should be handled via a WM_VSCROLL message as below:

//Indentation to move the window by VERT_PTS on each scrolling
// action. This you can change as per your requirement
#define VERT_PTS 5  
void CProppageLarge::OnVScroll(UINT nSBCode, UINT nPos,
    CScrollBar* pScrollBar) 
    // TODO: Add your message handler code here and/or call default
    int nInc; // The Increment required for Scrollbar from Current Position
    // Select the Mode of Scrolling and set the Increment position
    // variable accordingly
    switch (nSBCode)
        case SB_TOP:        nInc = -m_nVscrollPos;               break;
        case SB_BOTTOM:     nInc = m_nVscrollMax-m_nVscrollPos;  break;
        case SB_LINEUP:     nInc = -1;                           break;
        case SB_LINEDOWN:   nInc = 1;                            break;
        case SB_PAGEUP:     nInc = min(-1, -m_nVertInc);         break;
        case SB_PAGEDOWN:   nInc = max(1, m_nVertInc);           break;
        case SB_THUMBTRACK: nInc = nPos - m_nVscrollPos;         break;
        default:            nInc = 0;

    // Fetch the Current Position and set the Increment Variable from
    // the Current Position
    nInc = max(-m_nVscrollPos, min(nInc, m_nVscrollMax - m_nVscrollPos));

    // If the Position is changed ,move the Scrollbar and the Window too
    if (nInc)
        m_nVscrollPos += nInc;
        int iMove = -VERT_PTS * nInc;
        ScrollWindow(0, iMove, NULL, NULL);
        SetScrollPos(SB_VERT, m_nVscrollPos, TRUE);

   Cpropertypage::OnVScroll(nSBCode, nPos, pScrollBar);

Here I have added the handler only for vertical scrolling but it can be updated for horizontal scrolling or both as per your need in the type of property page.


This is my first article on CodeProject and I have yet to learn a lot. I would definitely like to thank Mr. Trilok Soni (Tectona SoftSolutions(P) Ltd) for inspiring me to write articles and Mr. Paras Shah (VIP Benefits) for giving a major spur to this article. I assure all of you of very interesting articles in the very near future. I would definitely like to hear valuable suggestions from not only those who use this but all the senior programmers too, as it will improve my learning curve.


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

Web Developer
United States United States
Jemin is Working as Software Engineer in Tectona SoftSolutions(P) Ltd, Ahmedabad.

You may also be interested in...

Comments and Discussions

QuestionAccessing Controls From Other Tabs? Pin
overloaded Name18-Apr-12 21:55
memberoverloaded Name18-Apr-12 21:55 
GeneralThanks Pin
cwcarter157-Feb-09 0:54
membercwcarter157-Feb-09 0:54 
GeneralExactly what i needed Pin
Opa Knack13-Nov-08 1:14
memberOpa Knack13-Nov-08 1:14 
Questionminimal width of cpropertypage Pin
eomer21227-Aug-07 6:58
membereomer21227-Aug-07 6:58 
GeneralNice Work! Pin
.Suchit29-Jul-06 0:16
member.Suchit29-Jul-06 0:16 
QuestionWhen I click on the scroll bars, it looks blank? Pin
DanYELL22-Jan-06 3:39
memberDanYELL22-Jan-06 3:39 
General"Please enter an integer" Problem! Pin
epeyman19-Jul-05 12:23
memberepeyman19-Jul-05 12:23 
QuestionHow to resize at runtime Pin
xavlec20-Sep-04 1:02
memberxavlec20-Sep-04 1:02 
GeneralNavigation using tab key Pin
Bijawara N Krishnaswamy24-Mar-04 18:13
sussBijawara N Krishnaswamy24-Mar-04 18:13 
Thanx for scrollable property page. But we can not use tab keys to navigate. Though the control has the focus, scrolling is required to make it visible
Can any one please tell the solution.
Thanx in advance

GeneralRe: Navigation using tab key Pin
Member 30576882-Sep-09 21:30
memberMember 30576882-Sep-09 21:30 
GeneralRe: Navigation using tab key Pin
binyo6610-Aug-10 0:09
memberbinyo6610-Aug-10 0:09 
QuestionCan v place the Property sheets vertically on the left corner? Pin
elza4-Feb-04 23:29
memberelza4-Feb-04 23:29 
GeneralScrolled property page under PocketPC Pin
esmi3-Sep-03 3:34
memberesmi3-Sep-03 3:34 
GeneralRe: Scrolled property page under PocketPC Pin
dweiss0214-Jul-04 5:23
memberdweiss0214-Jul-04 5:23 
GeneralRe: Scrolled property page under PocketPC Pin
rockone25-Oct-04 23:54
memberrockone25-Oct-04 23:54 
GeneralRe: Scrolled property page under PocketPC Pin
esmi26-Oct-04 0:26
memberesmi26-Oct-04 0:26 
GeneralRe: Scrolled property page under PocketPC Pin
rockone26-Oct-04 16:24
memberrockone26-Oct-04 16:24 
GeneralRe: Scrolled property page under PocketPC Pin
esmi26-Oct-04 20:34
memberesmi26-Oct-04 20:34 
GeneralRe: Scrolled property page under PocketPC Pin
rockone27-Oct-04 16:49
sussrockone27-Oct-04 16:49 
GeneralRe: Scrolled property page under PocketPC Pin
esmi27-Oct-04 20:59
memberesmi27-Oct-04 20:59 
GeneralRe: Scrolled property page under PocketPC Pin
rockone31-Oct-04 15:03
sussrockone31-Oct-04 15:03 
GeneralRe: Scrolled property page under PocketPC Pin
Divyang Mithaiwala10-Sep-06 21:51
memberDivyang Mithaiwala10-Sep-06 21:51 
GeneralPlease........some unclear... >_< Pin
jacky1128723-May-03 23:41
memberjacky1128723-May-03 23:41 
GeneralPlease Complete Pin
Hossein Mehry12-Apr-03 8:36
memberHossein Mehry12-Apr-03 8:36 
GeneralRe: Please Complete Pin
Tili3-Jul-03 2:44
memberTili3-Jul-03 2:44 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170424.1 | Last Updated 2 Apr 2003
Article Copyright 2003 by Jemin
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid