Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Minimize box to MFC Property Sheet system menu

Tags:

visual-c++

mfc

How could I Add Minimize and Maximize box to the system menu of CMFCPropertySheet. I have tried modifying the style by

CMFCPropertySheet::ModifyStyle(NULL, WS_SYSMENU);

but nothing happened.

like image 410
AMCoded Avatar asked Jan 18 '12 08:01

AMCoded


People also ask

How to add property Sheet in MFC?

Step 1 − Right-click on your project and select Add > Class menu options. Step 2 − Select Visual C++ → MFC from the left pane and MFC Class in the template pane and click Add. Step 3 − Enter the class name and select CPropertySheet from base class dropdown list. Step 4 − Click finish to continue.

What is a property sheet in MFC?

A property sheet, also known as a tab dialog box, provides a way to manage large numbers of controls in a dialog box. The property sheet contains property pages, each based on a separate dialog template resource. You can divide your dialog box's controls into logical groups and put each group on its own property page.


1 Answers

Assuming you have a class derived from CPropertySheet, let's call it MySheet:

// Capture the WM_NCREATE message
BEGIN_MESSAGE_MAP(CMySheet, CPropertySheet)
  ON_WM_NCCREATE()
END_MESSAGE_MAP()

BOOL CMySheet::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
{
  if (!CPropertySheet::OnNcCreate(lpCreateStruct))
    return FALSE;

  // Modify the window style
  LONG dwStyle = ::GetWindowLong(m_hWnd, GWL_STYLE);
  ::SetWindowLong(m_hWnd, GWL_STYLE, dwStyle | WS_WS_MINIMIZEBOX | WS_MAXIMIZEBOX);

  return TRUE;
}

Note that you could do this in the OnInitDialog, but even though the Minimize/Maximize boxes will show, they won't do anything.

like image 191
Eddie Paz Avatar answered Sep 23 '22 10:09

Eddie Paz