Solved

Sizing Property Sheets

Posted on 1998-08-24
1
299 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

829 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