MainFrm.cpp
资源名称:vc开发gis代码.rar [点击查看]
上传用户:jndfzt02
上传日期:2007-04-25
资源大小:391k
文件大小:6k
源码类别:
GIS编程
开发平台:
Visual C++
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- #include "stdafx.h"
- #include "Draw.h"
- #include "Drawdoc.h"
- #include "Drawview.h"
- #include "MainFrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- class CDrawDoc;
- class CDrawView;
- CMemFile pFile;
- IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
- BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_CREATE()
- ON_COMMAND(ID_EDIT_CC, OnEditCut)
- ON_COMMAND(ID_VIEW_TOOLBAR1, OnViewToolbar1)
- ON_UPDATE_COMMAND_UI(ID_VIEW_TOOLBAR1, OnUpdateViewToolbar1)
- ON_COMMAND(ID_WINDOW_NEW, OnWindowNew)
- ON_COMMAND(ID_VIEW_DATABASE, OnViewDatabase)
- //}}AFX_MSG_MAP
- // Global help commands
- ON_COMMAND(ID_HELP_FINDER, CMDIFrameWnd::OnHelpFinder)
- ON_COMMAND(ID_HELP, CMDIFrameWnd::OnHelp)
- ON_COMMAND(ID_CONTEXT_HELP, CMDIFrameWnd::OnContextHelp)
- ON_COMMAND(ID_DEFAULT_HELP, CMDIFrameWnd::OnHelpFinder)
- END_MESSAGE_MAP()
- static UINT BASED_CODE indicators[] =
- {
- ID_SEPARATOR,
- ID_SEPARATOR,
- ID_SEPARATOR,
- ID_SEPARATOR,
- };
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame construction/destruction
- CMainFrame::CMainFrame()
- {
- // TODO: add member initialization code here
- BOOL YN=pFile.Open("undo.dat",CFile::modeReadWrite|CFile::typeBinary|CFile::modeCreate);
- if(YN)
- {
- YN=FALSE;
- pFile.Write((unsigned char *)&YN,sizeof(YN));
- }
- }
- CMainFrame::~CMainFrame()
- {
- pFile.Close();
- }
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- if (!m_wndToolBar.Create(this) ||
- !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- TRACE0("Failed to create status barn");
- return -1; // fail to create
- }
- //设置各指示器的风格和宽度
- m_wndStatusBar.SetPaneInfo(1,300,SBPS_NORMAL,180);
- m_wndStatusBar.SetPaneInfo(2,301,SBPS_NORMAL,80);
- m_wndStatusBar.SetPaneInfo(3,302,SBPS_NORMAL,80);
- m_wndStatusBar.SetPaneInfo(0,304,SBPS_STRETCH,80);
- // TODO: Remove this if you don't want tool tips or a resizeable toolbar
- m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
- CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
- // 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_wndToolBar1.Create(this) ||
- !m_wndToolBar1.LoadToolBar(IDR_TOOLBAR1))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
- m_wndToolBar1.SetBarStyle(m_wndToolBar1.GetBarStyle() |
- CBRS_FLOATING | CBRS_FLYBY );
- // TODO: Delete these three lines if you don't want the toolbar to
- // be dockable
- m_wndToolBar1.EnableDocking(CBRS_ALIGN_LEFT);
- EnableDocking(CBRS_ALIGN_LEFT);
- DockControlBar(&m_wndToolBar1);
- if(!m_wndDlgBar.Create(this,IDD_DIALOGBAR,CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY,IDD_DIALOGBAR))
- {
- TRACE0("Failed to Create DialogBarn");
- return -1;
- }
- m_wndDlgBar.SetDlgItemText(IDC_EDIT1,"1");
- CComboBox *p_Com=(CComboBox *)m_wndDlgBar.GetDlgItem(IDC_COMBO1);
- p_Com->ResetContent();
- p_Com->AddString("PS_SOLID _________");
- p_Com->AddString("PS_DASH __ __ __ ");
- p_Com->AddString("PS_DOT _ _ _ _ _");
- p_Com->AddString("PS_DASHDOT _ __ _ __ _ __");
- p_Com->AddString("PS_DASHDOTDOT _ _ __ _ _ __");
- p_Com->AddString("PS_NULL _________");
- p_Com->AddString("PS_INSIDEEFRAME _________");
- p_Com->SetCurSel(0);
- return 0;
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CMDIFrameWnd::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // 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::OnEditCut()
- {
- CDrawDoc *pDoc=(CDrawDoc *)GetActiveDocument();
- CDrawView* pView=(CDrawView *)GetActiveView();
- pView->Invalidate();
- // float x=pDoc->n_GraphSelect;
- // TODO: Add your command handler code here
- }
- void CMainFrame::OnViewToolbar1()
- {
- // TODO: Add your command handler code here
- BOOL bVisible=((m_wndToolBar1.GetStyle()&WS_VISIBLE)!=0);
- ShowControlBar(&m_wndToolBar1,!bVisible,FALSE);
- RecalcLayout();
- }
- void CMainFrame::OnUpdateViewToolbar1(CCmdUI* pCmdUI)
- {
- BOOL bVisible=((m_wndToolBar1.GetStyle()&WS_VISIBLE)!=0);
- pCmdUI->SetCheck(bVisible);
- }
- void CMainFrame::OnWindowNew()
- {
- // TODO: Add your command handler code here
- CMDIChildWnd* pActiveChild = MDIGetActive();
- CDocument* pDocument;
- if (pActiveChild == NULL ||
- (pDocument = pActiveChild->GetActiveDocument()) == NULL)
- {
- TRACE0("Warning: No active document for WindowNew command.n");
- AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
- return; // command failed
- }
- CDrawApp* pApp=(CDrawApp*)AfxGetApp();
- CDocTemplate* pTemplate =pApp->GetDocTemplate1();
- ASSERT_VALID(pTemplate);
- CFrameWnd* pFrame =pTemplate->CreateNewFrame(pDocument, pActiveChild);
- if (pFrame == NULL)
- {
- TRACE0("Warning: failed to create new frame.n");
- return; // command failed
- }
- pTemplate->InitialUpdateFrame(pFrame, pDocument);
- }
- void CMainFrame::OnViewDatabase()
- {
- CMDIChildWnd* pActiveChild = MDIGetActive();
- CDocument* pDocument;
- if (pActiveChild == NULL ||
- (pDocument = pActiveChild->GetActiveDocument()) == NULL)
- {
- TRACE0("Warning: No active document for WindowNew command.n");
- AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
- return; // command failed
- }
- CDrawApp* pApp=(CDrawApp*)AfxGetApp();
- CDocTemplate* pTemplate =pApp->GetDocTemplate1();
- ASSERT_VALID(pTemplate);
- CFrameWnd* pFrame =pTemplate->CreateNewFrame(pDocument, pActiveChild);
- if (pFrame == NULL)
- {
- TRACE0("Warning: failed to create new frame.n");
- return; // command failed
- }
- pTemplate->InitialUpdateFrame(pFrame, pDocument);
- }