Stack Window

WEBINAR: On-demand webcast

How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >

.

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


Comments

  • 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.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date