Click here to Skip to main content
15,891,567 members
Articles / Desktop Programming / MFC

Understanding CDockablePane

Rate me:
Please Sign up or sign in to vote.
4.95/5 (80 votes)
19 Aug 2015Apache12 min read 362.2K   11.8K   134  
A good reference for CDockablePane
#include "stdafx.h"
#include "resource.h"
#include "PhoneBook.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

#define IDC_OUTLOOK 100
#define IDC_TABCTRL 101

IMPLEMENT_DYNAMIC(PhoneBook, CDialog)
BEGIN_MESSAGE_MAP(PhoneBook, CDialog)
	ON_WM_CREATE()
	ON_WM_SIZE()
END_MESSAGE_MAP()

PhoneBook::PhoneBook(CWnd* pParent /*=NULL*/)
	: CDialog(PhoneBook::IDD, pParent)
{
}

PhoneBook::~PhoneBook()
{
}

int PhoneBook::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CDialog::OnCreate(lpCreateStruct) == -1)
		return -1;

	CRect rect;
	GetClientRect(&rect);
	rect.bottom = int(rect.Height() * 0.9);
	m_wndOutlook.Create(rect,this,IDC_OUTLOOK);
	m_dlgSimple.Create(IDD_SIMPLE,this);
	m_wndTabCtrl.Create(CMFCTabCtrl::STYLE_3D_ONENOTE,rect,this,IDC_TABCTRL,CMFCBaseTabCtrl::LOCATION_TOP);
	m_dlgSimple.SetOwner(&m_wndOutlook);
	m_wndTabCtrl.SetOwner(&m_wndOutlook);
	m_wndOutlook.AddTab(&m_dlgSimple,_T("Simple"));
	m_wndOutlook.AddTab(&m_wndTabCtrl,_T("Advanced"));
	m_dlgMain.Create(IDD_MAIN,&m_wndTabCtrl);
	m_wndTabCtrl.AddTab(&m_dlgMain,_T("Main"));
	m_dlgWork.Create(IDD_WORK,&m_wndTabCtrl);
	m_wndTabCtrl.AddTab(&m_dlgWork,_T("Work"));
	m_dlgHome.Create(IDD_HOME,&m_wndTabCtrl);
	m_wndTabCtrl.AddTab(&m_dlgHome,_T("Home"));
	m_dlgGeneral.Create(IDD_GENERAL,&m_wndTabCtrl);
	m_wndTabCtrl.AddTab(&m_dlgGeneral,_T("General"));
	return 0;
}

void PhoneBook::OnSize(UINT nType, int cx, int cy)
{
	CDialog::OnSize(nType, cx, cy);
	int Height = int(cy * 0.9);//take 90% of parent dialog height
	m_wndOutlook.MoveWindow(0,0,cx,Height);
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0


Written By
Software Developer (Senior)
Syrian Arab Republic Syrian Arab Republic
C++ , MFC , Win32 professional Developer.

Comments and Discussions