|
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "pindock.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
IMPLEMENT_PINDOCK(CMainFrame)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_COMMAND(ID_VIEW_INSTANTBAR, OnViewInstantbar)
ON_UPDATE_COMMAND_UI(ID_VIEW_INSTANTBAR, OnUpdateViewInstantbar)
ON_COMMAND(ID_VIEW_MYBAR2, OnViewMybar2)
ON_UPDATE_COMMAND_UI(ID_VIEW_MYBAR2, OnUpdateViewMybar2)
ON_COMMAND(ID_VIEW_MYBAR2_1, OnViewMybar21)
ON_UPDATE_COMMAND_UI(ID_VIEW_MYBAR2_1, OnUpdateViewMybar21)
//}}AFX_MSG_MAP
ON_PINDOCK_MESSAGES()
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnablePinDocking(CBRS_ALIGN_ANY);
//EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
m_ImgList.Create(IDB_TAB, 16, 1, RGB(255,0,255));
for(int i = 0;i < 4; i ++)
m_AutoHideBar[i].SetImageList(&m_ImgList);
if (!m_MyBar.Create(_T("Instant Bar"), this, 127))
{
TRACE0("Failed to create instant bar\n");
return -1; // fail to create
}
m_MyBar.SetSCBStyle(m_MyBar.GetSCBStyle() |
SCBS_SIZECHILD);
m_MyBar.SetBarStyle(m_MyBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_MyBar.EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_MyBar, AFX_IDW_DOCKBAR_LEFT);
if (!m_MyBar2.Create(_T("My Bar2"), this, 127))
{
TRACE0("Failed to create my bar2\n");
return -1; // fail to create
}
m_MyBar2.SetSCBStyle(m_MyBar.GetSCBStyle() |
SCBS_SIZECHILD);
m_MyBar2.SetBarStyle(m_MyBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_MyBar2.EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_MyBar2, AFX_IDW_DOCKBAR_RIGHT);
if (!m_MyBar2_1.Create(_T("My Bar2_1"), this, 128))
{
TRACE0("Failed to create my bar2_1\n");
return -1; // fail to create
}
m_MyBar2_1.SetSCBStyle(m_MyBar.GetSCBStyle() |
SCBS_SIZECHILD);
m_MyBar2_1.SetBarStyle(m_MyBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_MyBar2_1.EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_MyBar2_1, AFX_IDW_DOCKBAR_RIGHT);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::OnViewInstantbar()
{
// TODO: Add your command handler code here
BOOL bShow = m_MyBar.IsVisible();
ShowControlBar(&m_MyBar, !bShow, FALSE);
}
void CMainFrame::OnUpdateViewInstantbar(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(m_MyBar.m_Tree.GetParent() == &(m_MyBar.m_tabctrl));
pCmdUI->SetCheck(m_MyBar.IsVisible());
}
void CMainFrame::OnViewMybar2()
{
// TODO: Add your command handler code here
BOOL bShow = m_MyBar2.IsVisible();
ShowControlBar(&m_MyBar2, !bShow, FALSE);
}
void CMainFrame::OnUpdateViewMybar2(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(m_MyBar2.m_List.GetParent() == &m_MyBar2);
pCmdUI->SetCheck(m_MyBar2.IsVisible());
}
void CMainFrame::OnViewMybar21()
{
// TODO: Add your command handler code here
BOOL bShow = m_MyBar2_1.IsVisible();
ShowControlBar(&m_MyBar2_1, !bShow, FALSE);
}
void CMainFrame::OnUpdateViewMybar21(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(m_MyBar2_1.m_List.GetParent() == &m_MyBar2_1);
pCmdUI->SetCheck(m_MyBar2_1.IsVisible());
}
|
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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.