1 // OCC_MainFrame.cpp: implementation of the OCC_MainFrame class.
3 //////////////////////////////////////////////////////////////////////
7 #include "OCC_MainFrame.h"
9 #include <res\OCC_Resource.h>
11 /////////////////////////////////////////////////////////////////////////////
14 IMPLEMENT_DYNAMIC(OCC_MainFrame, CMDIFrameWnd)
16 BEGIN_MESSAGE_MAP(OCC_MainFrame, CMDIFrameWnd)
17 //{{AFX_MSG_MAP(OCC_MainFrame)
18 // NOTE - the ClassWizard will add and remove mapping macros here.
19 // DO NOT EDIT what you see in these blocks of generated code !
22 ON_COMMAND(ID_HELP_FINDER, CMDIFrameWnd::OnHelpFinder)
25 static UINT indicators[] =
27 ID_SEPARATOR, // status line indicator
33 /////////////////////////////////////////////////////////////////////////////
34 // OCC_MainFrame construction/destruction
36 OCC_MainFrame::OCC_MainFrame(BOOL withAISToolBar /*=false*/)
38 m_withAISToolBar=withAISToolBar;
40 m_AISToolBar = new CToolBar;
46 OCC_MainFrame::~OCC_MainFrame()
48 if (m_AISToolBar) delete m_AISToolBar;
51 int OCC_MainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
53 if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
56 if (!m_wndToolBar.Create(this) ||
57 !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
59 TRACE0("Failed to create toolbar\n");
60 return -1; // fail to create
63 if (m_withAISToolBar){
64 if (!m_AISToolBar->Create(this) ||
65 !m_AISToolBar->LoadToolBar(IDR_TB_AIS))
67 TRACE0("Failed to create toolbar\n");
68 return -1; // fail to create
72 if (!m_wndStatusBar.Create(this) ||
73 !m_wndStatusBar.SetIndicators(indicators,
74 sizeof(indicators)/sizeof(UINT)))
76 TRACE0("Failed to create status bar\n");
77 return -1; // fail to create
80 // TODO: Remove this if you don't want tool tips or a resizeable toolbar
81 m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
82 CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
84 // TODO: Delete these three lines if you don't want the toolbar to
86 m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
87 EnableDocking(CBRS_ALIGN_ANY);
88 DockControlBar(&m_wndToolBar,AFX_IDW_DOCKBAR_TOP);
89 if (m_withAISToolBar){
90 m_AISToolBar->SetBarStyle(m_AISToolBar->GetBarStyle() |
91 CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
92 m_AISToolBar->EnableDocking(CBRS_ALIGN_ANY);
93 DockControlBarLeftOf(m_AISToolBar,&m_wndToolBar);
98 /////////////////////////////////////////////////////////////////////////////
99 // OCC_MainFrame diagnostics
102 void OCC_MainFrame::AssertValid() const
104 CMDIFrameWnd::AssertValid();
107 void OCC_MainFrame::Dump(CDumpContext& dc) const
109 CMDIFrameWnd::Dump(dc);
114 void OCC_MainFrame::SetStatusMessage(const CString & message)
116 m_wndStatusBar.SetWindowText(message);
120 BOOL OCC_MainFrame::PreCreateWindow(CREATESTRUCT& cs)
122 // TODO: Modify the Window class or styles here by modifying
123 // the CREATESTRUCT cs
124 return CMDIFrameWnd::PreCreateWindow(cs);
127 void OCC_MainFrame::DockControlBarLeftOf(CToolBar* Bar,CToolBar* LeftOf)
133 // get MFC to adjust the dimensions of all docked ToolBars
134 // so that GetWindowRect will be accurate
136 LeftOf->GetWindowRect(&rect);
137 rect.OffsetRect(1,0);
138 dw=LeftOf->GetBarStyle();
140 n = (dw&CBRS_ALIGN_TOP) ? AFX_IDW_DOCKBAR_TOP : n;
141 n = (dw&CBRS_ALIGN_BOTTOM && n==0) ? AFX_IDW_DOCKBAR_BOTTOM : n;
142 n = (dw&CBRS_ALIGN_LEFT && n==0) ? AFX_IDW_DOCKBAR_LEFT : n;
143 n = (dw&CBRS_ALIGN_RIGHT && n==0) ? AFX_IDW_DOCKBAR_RIGHT : n;
145 // When we take the default parameters on rect, DockControlBar will dock
146 // each Toolbar on a seperate line. By calculating a rectangle, we in effect
147 // are simulating a Toolbar being dragged to that location and docked.
148 DockControlBar(Bar,n,&rect);