Stack Window


Sample Image

Overview on stack window

The stack window gives alternative way to manage multiple dialog boxes inside single window (see picture). Unlike standard property sheet control layout of stack window is vertical. Pages are separated with captions. Page captions displays user-defined name and can be clicked to expand/contract the page. If size of stack window exceeds size of parent's client area user can pan window contents by clicking and dragging on the whitespace area or static/disabled control of child dialog box.

How to use stack window in your application

1. Add member variable in your CMainFrame class:

CStackWnd m_wndStack;

2. Create stack window during main frame creation

   int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	if (!m_wndStack.Create(NULL, NULL, WS_CHILD | WS_VISIBLE,
		CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
		TRACE0("Failed to create view window\n");
		return -1;


3. Create dialog box template and dialog box class. Dialog box should be invisible child.

4. Insert a page into stack window

CDialog* pDlg;
pDlg = new CMyDialog;
m_wndStack.InsertPage(pDialog, IDD_MY_DIALOG, _T("My dialog"),

5. Return to step 3 to add more pages.

Page flags

The combination of following values can be passed to dwFlags parameter of CStackWnd::InsertPage:

Page is visible

Page is contracted (i.e. only caption is visible)


You should ensure the size of parent window is less or equal to size of the child stack window.


Download demo project - 64 Kb
Download source - 9 Kb