A Simple Tabbed MDI for WTL

A Simple Tabbed MDI for WTL

Sample Image - wtlmditab.gif

Introduction

This class adds a simple tab control in a WTL based MDI application. It is partly based on the freeware MFC version from Dundas Software available at:

Usage

First, include the header file and create a CMDITabImpl member in the main frame class.

C++
#include "atlmditab.h"

...
class CMainFrame : public ....
{
    CMDITabImpl<CMainFrame> m_TabbedMDI;

Then attach to the control in main frame's OnCreate(..) function:

C++
LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, 
    LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
    ....
    CreateMDIClient();
    m_CmdBar.SetMDIClient(m_hWndMDIClient);
    m_TabbedMDI.Attach(this);
    ...
}

Then you must add an UpdateLayout() function in main frame to place the tab control correctly. If anybody finds a solution for WTL that won't require this extra code, please let me know.

C++
void UpdateLayout(BOOL bResizeBars = TRUE)
{
    RECT rect;
    GetClientRect(&rect);
    
    // position bars and offset their dimensions
    UpdateBarsPosition(rect, bResizeBars);
        
    m_TabbedMDI.UpdateTabLayout(m_hWndClient, rect);
}

Limitations

This class is written for learning WTL, so there are surely lots of bugs in the implementation. And some features are not implemented yet, like icon support and context menu. I will work on them later when I get more time. Cheers!

History

  • 23rd December, 2001: Initial version

License

This article has no explicit license attached to it, but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below.

A list of licenses authors might use can be found here.

posted @ 2022-12-13 14:04  小风风的博客  阅读(18)  评论(0编辑  收藏  举报