Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Sizing Property Sheets

Posted on 1998-08-24
1
Medium Priority
?
303 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
[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
 
LVL 2

Accepted Solution

by:
milenvk earned 200 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

636 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