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"),
SWF_VISIBLE);

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:

SWF_VISIBLE
Page is visible

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

Caution

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

Downloads

Download demo project - 64 Kb
Download source - 9 Kb

IT Offers

Comments

  • Lightweight perceptive – Nike Loose TR Attack in spring 2013 3 series

    Posted by Tufffruntee on 04/19/2013 05:10am

    Nike Free TR Suited 3 prominent features is to use the additional forge: Nike Let off 5 soles improved bending Groove; new tractor pattern making training more focused when; lighter ballast, the permeability is stronger, and more in fashion shoe designs not just order shoes [url=http://fossilsdirect.co.uk/glossarey.cfm]nike huarache free[/url] more smug wearing, barefoot training sensible of, but also more in vogue appearance. Nike Manumitted TR Fitting 3 provides supreme lateral stability, you can be suffering with the legs in the part during training. Strong vamp superiority breathable mesh, lower soap up's unique delineate can be [url=http://markwarren.org.uk/goodbuy.cfm]nike free run uk[/url] seen by virtue of it. Lightweight, demanding, pinched bubbles facts habituated to at hand entirely some seams, more amenable, support is stronger. Lack more mainstay, role of a training irritate, lather come in more parts of the need after agreeableness, bubble loose. Use double patois moisture wicking fake materials, tiresome on your feet, help maintain feet tiring and comfortable. Phylite [url=http://northernroofing.co.uk/roofins.cfm]nike free[/url] midsole offers lightweight stupor level, famous durability and unbroken outsole can do to greatly reduce the comprehensive load of the shoe. Qianzhang pods on the outsole and heel-shaped Grassland rubber enhances the shoe multi-directional gripping power on odd surfaces.

    Reply
  • Stack Window

    Posted by Legacy on 12/28/1999 12:00am

    Originally posted by: Masoud

    Hi every body,

    Cool thing!, But i've been trying to add it to a CFormView
    inside the LefPane of a splitted (2,1) child view app.

    It don't give what i want, instead it loads only the empty form without the stack window or the controls dialog pages on it, just plane sheet!

    I wonder any one can help?

    Thank you and Merry Xmas with wishes for a very happy 2000.

    Masoud.
    marcello43@hotmail.com

    Reply
  • used sample to create a dialogbar

    Posted by Legacy on 10/11/1999 12:00am

    Originally posted by: wolfram

    wow, very good.
    I used the StackWnd class as a sample to create a cool dialogbar. I devired the StackWnd class from CControlBar instead of CWnd and added some changes for control bar behavier. If someone would like to get the code, send a mail and i will publish it here.

    Reply
  • not really a bug, but it's better to be fixed ..

    Posted by Legacy on 09/09/1999 12:00am

    Originally posted by: alexander

    First of all, this is really cool stuff.

    As to the problem : you are missing DT_SINGLELINE flag in CDC::DrawText() call, thus making DT_VCENTER flag meaningless (refer to the mfc docs). See code below for the fix.

    Another comment is that I believe it would be more appropriate to define member variable of type CFont and initialize it once (say, in [PrecreateWindow]) and then just use it in [DrawPageCaption]. Plus you would be able more accurately compute the value of [m_cyCaption] as it depends on the font chars.

    void CStackWnd::DrawPageCaption(...)
    {
    ...

    if (lpszText)
    {
    ...

    pDC->DrawText(lpszText, lpRect,
    DT_CENTER | DT_VCENTER | DT_SINGLELINE);
    }
    }

    Regards,
    alexander.

    Reply
  • Memory leaks :(

    Posted by Legacy on 09/01/1999 12:00am

    Originally posted by: Jack

    Nice job, but on closing of stack window
    
    dialogs stays in the memory.

    The solution is:

    void CStackWnd::ClearPageInfo()
    {
    CPageInfo* ptr = m_pPageInfo, *ptrNext;
    while (ptr)
    {
    ptrNext = ptr->m_pNext;

    // !! This line solve the problem:
    delete ptr->m_pDlg;

    delete ptr;
    ptr = ptrNext;
    }

    m_pPageInfo = NULL;
    }


    Reply
  • Suggestion: indicators

    Posted by Legacy on 08/19/1999 12:00am

    Originally posted by: Tomaz Stih

    It`s a cool class. How about a little improvement? Since there is no scroll bar user has no way of knowing that there is more info above the window limit. Maybe adding cool looking up and down indicators would be an improvement.

    --tomaz

    Reply
  • Font Problems under Win98 1st Edition

    Posted by Legacy on 08/15/1999 12:00am

    Originally posted by: Wraith Zero

    All in all, a nice little feature!  Thanks for the contribution!
    
    

    However, in testing I encountered some problems with fonts on the page captions ...

    In the DrawPageCaption() method, simply replace the existing

    if (lpszText)
    {
    ...
    }

    clause with the one below:

    // draw text
    if (lpszText)
    {
    CFont font;
    LOGFONT lf;
    WU_GetDefaultGUIFont(8, &lf);
    font.CreateFontIndirect(&lf);

    //$ WRAITH: Preserve previous font
    CFont *pfontOld = (CFont*)pDC->SelectObject(&font);

    pDC->SetTextColor(GetSysColor(COLOR_BTNTEXT));
    pDC->SetBkMode(TRANSPARENT);
    pDC->DrawText(lpszText, lpRect, DT_CENTER | DT_VCENTER);

    //$ WRAITH: Restore original font
    pDC->SelectObject(pfontOld);
    }

    Also, I've found some painting anomalies which occur when dragging the client area around and resizing the dialog to its full normal size ... though I haven't had the time to look into it yet.

    Thanks for the great work and keep 'em coming!

    - Wraith Z

    Reply
  • Круто

    Posted by Legacy on 08/05/1999 12:00am

    Originally posted by: Alex II

    Просто круто

    Reply
  • Way Cool!

    Posted by Legacy on 07/29/1999 12:00am

    Originally posted by: Alex

    Nice job, Tim! It's got that 3D Studio MAX look and feel.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Go Deeper

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds