?
Solved

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

Posted on 2000-03-07
1
Medium Priority
?
546 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

770 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