Solved

How to dynamically change size of a property page in property sheet?

Posted on 2000-03-07
1
534 Views
Last Modified: 2013-11-20
I have a property sheet dialog box with two property pages.
  I have a button(say labled "resize") on one of my property pages.On pressing that button I want to change the size of the property sheet dialog box.
  How is it possible?
  Moreover I want to place the "OK","CANCEL","APPLY" buttons of property sheet at desired locations on dialog box.How is this also possible?


How to dynamically change size of a property page in property sheet?
0
Comment
Question by:sjhunjhunuwala
1 Comment
 

Accepted Solution

by:
maknight earned 50 total points
ID: 2591452
A bit more involved than a 50-pointer, but here goes. . . The trick here, is to actually create the dialog as the largest you want it, add a control (usually a "line") that you can key off of as the bottom of the smallest version of the dialog, and then redraw as needed. You can create a "line" by using the picture frame and collapsing it all the way down. Here's some code as I used it.

    // get current dialog window rectangle
    CRect rcDialog;
    GetWindowRect(&rcDialog);
    int nNewHeight = -1;

    if (bExpand)
        {
        // change caption
        pWndButton->SetWindowText(strLess);

        // calculate new dialog height
        CWnd* pWndLarge = GetDlgItem(nLargeID);
        ASSERT_VALID(pWndLarge);
        CRect rcLarge;
        pWndLarge->GetWindowRect(&rcLarge);
        nNewHeight = rcLarge.top - rcDialog.top;
        }
    else
        {
        // change caption
        pWndButton->SetWindowText(strMore);

        // calculate new dialog height
        CWnd* pWndSmall = GetDlgItem(nSmallID);
        ASSERT_VALID(pWndSmall);
        CRect rcSmall;
        pWndSmall->GetWindowRect(&rcSmall);
        nNewHeight = rcSmall.top - rcDialog.top;
        }

    // set new dialog height
    ASSERT(nNewHeight > 0);
    SetWindowPos(NULL, 0, 0, rcDialog.Width(), nNewHeight, SWP_NOMOVE | SWP_NOZORDER);

    // set the enabled state for controls depending on whether visible or not
    CWnd* pWndControl = GetWindow(GW_CHILD);
    while (pWndControl != NULL)
        {
        CRect rcControl;
        pWndControl->GetWindowRect(&rcControl);
        pWndControl->EnableWindow(rcControl.top <= rcDialog.top + nNewHeight);
        pWndControl = pWndControl->GetWindow(GW_HWNDNEXT);
        }
    CWnd* pWndActiveControl = CWnd::GetFocus();
    if (pWndActiveControl == NULL)
        {
        CWnd* pWndFirstControl = GetNextDlgTabItem(NULL);
        ASSERT_VALID(pWndFirstControl);
        ASSERT(pWndFirstControl->IsWindowEnabled());
        pWndFirstControl->SetFocus();
        }

As for the property page buttons... Use the OnInitDialog override, add a new function (say, MoveTheButtons), get the rectangle for each of the buttons one by one, using:

CWnd* pWndOK = pSheet->GetDialogItem(IDOK);
CRect rcOK;
pWndOK->GetWindowRect(&rcOK);
pWndOK->ScreenToClient(&rcOK);

Then, get the property sheet client rectangle using:
CRect rcClient;
pSheet->GetClientRect(&rcClient);

Next, computer your new desired locations, then call SetWindowPos for each button.

pWndOK->SetWindowPos(NULL, nCurrentX, nTop, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need to retreive data from .TFS file exported by DVR 8 218
repeatEnd java challenge 42 85
if loop in java 3 153
Sed question 2 101
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question