Solved

Sizing Property Sheets

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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 this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

910 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

19 Experts available now in Live!

Get 1:1 Help Now