Solved

Sizing Property Sheets

Posted on 1998-08-24
1
300 Views
Last Modified: 2013-11-19
I have a static splitter window which contains a CFormView-derived class in one pane.  I want to create a property sheet on this view so that it completely fills the pane by default.    I would also like to resize the property sheet if the window or pane is enlarged so that it still fills the available space.
0
Comment
Question by:fisham29
1 Comment
 
LVL 2

Accepted Solution

by:
milenvk earned 50 total points
ID: 1321221
Here's what I did when I had exactly the same problem:

In the CFormView derieved class declaration I have:

class CSheetView : public CFormView
{
..
public:
  CPropertySheet* m_pPropSheet;
.
  virtual void OnInitialUpdate();
.
  afx_msg void OnSize(UINT nType, int cx, int cy);
.
protected:
  void SizeWindows();
  void SizePage(CPropertyPage *pPage);
};

The implementation of these functions follows:

void CSheetView::OnInitialUpdate()
{
  ...    
  m_pPropSheet = new CPropertySheet("Property sheet", this);
  m_pPage1 = new CPage1;
  m_pPage2 = new CPage2;
 
  m_pPropSheet->AddPage(m_pPage1);
  m_pPropSheet->AddPage(m_pPage2);
  m_pPropSheet->Create(this, WS_CHILD, WS_EX_STATICEDGE);
  SizeWindows();
  m_pPropSheet->ShowWindow(SW_SHOW);
  ...
  CFormView::OnInitialUpdate();
}

//And here is the CSheetView::SizeWindows()implementation:

void CSheetView::SizeWindows()
{
  CRect rect, parentClientRect;
  CPropertyPage* p;
  CTabCtrl* pTab;

  if(m_pPropSheet)
  {
    GetClientRect(parentClientRect);
    parentClientRect.InflateRect(-1, -1);

    // Resize the parent window
    m_pPropSheet->MoveWindow(parentClientRect);

    // Resize the Tab control
    pTab = m_pPropSheet->GetTabControl();
    pTab->GetWindowRect(rect);
    m_pPropSheet->ScreenToClient(rect);
    rect.right = parentClientRect.right - 1;
    rect.bottom = parentClientRect.bottom - 1;
    pTab->MoveWindow(rect);

    // Resize the active page
    SizePage(m_pPropSheet->GetActivePage());
  }
}

//Here comes CSheetView::SizePage() function:

void CSheetView::SizePage(CPropertyPage *pPage)
{
  if(!pPage)
    return;
 
  CRect rect, parentRect;
  CWnd* pParent = pPage->GetParent();
  pParent->GetClientRect(parentRect);
  pPage->GetWindowRect(rect);
  pParent->ScreenToClient(rect);
  rect.right = parentRect.right - 5;
  rect.bottom = parentRect.bottom - 5;
  pPage->MoveWindow(rect);
}

// And finally call the SizeWindows() function in the WM_SIZE
// handler of the view
void CSheetView::OnSize(UINT nType, int cx, int cy)
{
  SizeWindows();
  CFormView::OnSize(nType, cx, cy);
}

0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Replacement selected text 2 66
how to monitor remote shell execution on linux 9 107
ffmpeg - "rtsp://...... Operation not permitted" 4 89
Problem to Office 1 43
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

749 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