|
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "[!output PROJECT_NAME].h"
#include "MainFrm.h"
#include "MainFrameDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CMainFrame
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
ON_WM_CLOSE()
ON_WM_CREATE()
ON_WM_ACTIVATE()
ON_WM_DESTROY()
ON_MESSAGE_VOID(WM_IDLEUPDATECMDUI, OnIdleUpdateCmdUI)
ON_MESSAGE(WM_OPENDOCUMENT,OnOpenDocument)
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()
{
POSITION pos;
CString key;
CObject* pManagedObj;
// Iterate through the entire map
for( pos = theApp.m_PrjItemDictionary.GetStartPosition(); pos != NULL; )
{
theApp.m_PrjItemDictionary.GetNextAssoc( pos, key, (CObject*&)pManagedObj );
delete pManagedObj;
}
theApp.m_PrjItemDictionary.RemoveAll();
TerminateExtLib();
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::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);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
theApp.m_pAppObj->OnCreate();
theApp.m_pAppObj->Fire_StartUp();
g_pDotNetExtImpl->m_pMainFrame = this;
g_pDotNetExtImpl->m_bCreateClient = true;
g_pDotNetExtImpl->OnCreate(RUNTIME_CLASS(CClientFrameWnd),RUNTIME_CLASS(CMainFrameDoc),::LoadBitmap(theApp.m_hInstance,_T("Background")));
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CMDIFrameWnd::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
{
CMDIFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CMDIFrameWnd::Dump(dc);
}
#endif //_DEBUG
// CMainFrame message handlers
void CMainFrame::OnClose()
{
if(g_pDotNetExtImpl->m_pApp->SaveAllModified())
{
theApp.m_pAppObj->Fire_AppClose();
theApp.m_pAppObj->OnClose();
g_pDotNetExtImpl->OnClose();
g_pDotNetExtImpl->m_pApp->CloseAllDocuments(FALSE);
CMDIFrameWnd::OnClose();
}
}
void CMainFrame::OnIdleUpdateCmdUI()
{
CMDIFrameWnd::OnIdleUpdateCmdUI();
g_pDotNetExtImpl->OnIdleUpdateCmdUI();
}
long CMainFrame::OnOpenDocument(WPARAM wParam, LPARAM lParam)
{
CWnd* pDeskWnd = CWnd::GetDesktopWindow();
CString strDocFile = _T("");
pDeskWnd->GetWindowText(strDocFile);
pDeskWnd->SetWindowText(_T(""));
g_pDotNetExtImpl->OpenDocumentFile(LPCTSTR(strDocFile));
return (long)0;
}
|
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 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