www.pudn.com > 2DCAD_duojiemian.rar > MainFrm.cpp
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "2DCAD.h"
#include "MainFrm.h"
#include "LineWidthDlg.h"
#include "2DCADView.h"
#include "2DCADDoc.h"
#include "TextView.h"
#include "ColorForm.h"
#include "TestDllDlg.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_COMMAND(ID_VIEW_GRAPHTOOLBAR, OnViewGraphtoolbar)
ON_UPDATE_COMMAND_UI(ID_VIEW_GRAPHTOOLBAR, OnUpdateViewGraphtoolbar)
ON_WM_TIMER()
ON_WM_CLOSE()
ON_COMMAND(ID_PROCESS_START, OnProcessStart)
ON_COMMAND(ID_DLL_MATH, OnDllMath)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_SEPARATOR,
ID_INDICATOR_TIME,
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);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
if (!m_newToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_newToolBar.LoadToolBar(IDR_TOOLBAR1))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_newToolBar.EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_newToolBar);
m_newToolBar.SetWindowText("Graph ToolBar");
m_wndToolBar.SetWindowText("Standard ToolBar");
SetTimer(1,1000,NULL);
CTime time;
time=CTime::GetCurrentTime();
CString str=time.Format("%H:%M:%S");
m_wndStatusBar.SetPaneText(m_wndStatusBar.CommandToIndex(ID_INDICATOR_TIME),str);
m_nLineStyleDlg.Create(IDD_LINESTYLE,this);
m_nLineStyleDlg.ShowWindow(SW_SHOW);
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::OnViewGraphtoolbar()
{
// TODO: Add your command handler code here
/* if(m_newToolBar.IsWindowVisible())
{
m_newToolBar.ShowWindow(SW_HIDE);
}
else
{
m_newToolBar.ShowWindow(SW_SHOW);
}
DockControlBar(&m_newToolBar);
RecalcLayout();*/
ShowControlBar(&m_newToolBar,!m_newToolBar.IsWindowVisible(),FALSE);
}
void CMainFrame::OnUpdateViewGraphtoolbar(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_newToolBar.IsWindowVisible());
}
void CMainFrame::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CTime time;
time=CTime::GetCurrentTime();
CString str=time.Format("%H:%M:%S");
m_wndStatusBar.SetPaneText(m_wndStatusBar.CommandToIndex(ID_INDICATOR_TIME),str);
CFrameWnd::OnTimer(nIDEvent);
}
void CMainFrame::OnClose()
{
// TODO: Add your message handler code here and/or call default
KillTimer(1);
CFrameWnd::OnClose();
}
//DEL void CMainFrame::OnSetLinewidth()
//DEL {
//DEL // TODO: Add your command handler code here
//DEL CLineWidthDlg dlg;
//DEL dlg.DoModal();
//DEL }
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
m_wndSplitter.CreateStatic(this,1,2);
m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CMy2DCADView),
CSize(450,250),pContext);
m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CColorForm),
CSize(250,250),pContext);
return 1;
// return CFrameWnd::OnCreateClient(lpcs, pContext);
}
void CMainFrame::OnProcessStart()
{
// TODO: Add your command handler code here
STARTUPINFO startupinfo; //声明初始信息结构对象
PROCESS_INFORMATION pInformation; //声明进程信息结构对象
startupinfo.cb=sizeof(STARTUPINFO);
startupinfo.cbReserved2=0;
startupinfo.lpDesktop=NULL;
startupinfo.lpTitle=NULL;
startupinfo.dwFlags=STARTF_USESHOWWINDOW;
startupinfo.lpReserved=NULL;
startupinfo.lpReserved2=NULL;
startupinfo.wShowWindow=SW_SHOW;
//调用CreateProcess函数产生新的进程
BOOL bgood=CreateProcess("Mut.exe", //可执行文件名
NULL, //需传递的命令行参数
NULL,
NULL,
FALSE,
0, //CREATE_DEFAULT_ERROR_MODE
NULL,
NULL,
&startupinfo, //初始信息,用作传入参数
&pInformation); //进程信息,用作接受参书
if(!bgood)
MessageBox("产生新的Mut进程失败");
}
void CMainFrame::OnDllMath()
{
// TODO: Add your command handler code here
CTestDllDlg dlg;
dlg.DoModal();
}