www.pudn.com > JingXiang-Design-Jeff.rar > MainFrm.cpp
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
//#include "DesignView.h"
#include "Design.h"
#include "MainFrm.h"
///
#include "DesignDoc.h"
#include "DesignView.h"
///
#include "Splash.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_WM_CLOSE()
ON_COMMAND(ID_VIEW_TOOLBAR, OnViewToolbar)
ON_UPDATE_COMMAND_UI(ID_VIEW_TOOLBAR, OnUpdateViewToolbar)
//}}AFX_MSG_MAP
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()
{
}
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
}
///////// Load Second Bar
if (!m_SecondToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_SecondToolBar.LoadToolBar(IDR_SECONDTOOLBAR))
{
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);
m_SecondToolBar.EnableDocking(CBRS_ALIGN_ANY);// Set For Second Tool Bar
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
DockControlBar(&m_SecondToolBar);// Set For Second Tool Bar
this->CenterWindow(GetDesktopWindow ());
// CG: The following line was added by the Splash Screen component.
CSplashWnd::ShowSplashScreen(this);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// Define Windows Size
//cs.x=100;
//cs.y=50;
cs.cx=640;
cs.cy=480;
cs.style&=~FWS_ADDTOTITLE;
//cs.style|=FWS_PREFIXTITLE;
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
BOOL CMainFrame::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
}
void CMainFrame::OnClose()
{
CDesignView *pDesignView;
pDesignView=(CDesignView*)GetActiveView();
if(pDesignView->IsAreaLocked||pDesignView->pPara_Detect->IsDetectBegin)
{
this->MessageBox("图像区域被锁定或正进行完形参数的测定,请先取消锁定或完成测定!","退出系统出现错误",MB_OK|MB_ICONERROR);
return;
}
if(this->MessageBox("真的要退出金相分析系统吗?","退出金相分析系统",MB_YESNO|MB_ICONWARNING)==IDNO) return;
CFrameWnd::OnClose();
return;
}
void CMainFrame::OnViewToolbar()
{
//CFrameWnd::Get
//m_m_wndToolBar.GetItemID(IDR_MAINFRAME)
//CToolBar::m
//CFrameWnd::OnBarCheck((UINT)m_wndToolBar.m_hWnd );// CFrameWnd::GetDlgItemInt(IDR_MAINFRAME));
BOOL IsToolBarShowed=m_SecondToolBar.GetStyle()&WS_VISIBLE;
CFrameWnd::OnBarCheck(AFX_IDW_TOOLBAR);
ShowControlBar(&m_SecondToolBar,!IsToolBarShowed,FALSE);
RecalcLayout();
}
void CMainFrame::OnUpdateViewToolbar(CCmdUI* pCmdUI)
{
OnUpdateControlBarMenu( pCmdUI);
//pCmdUI->SetCheck(IsToolBarShowed);
}