Solved

Sizing Property Sheets

Posted on 1998-08-24
1
292 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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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 remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now