www.pudn.com > Geotest.rar > MainFrm.cpp


// MainFrm.cpp : implementation of the CMainFrame class 
// 
 
#include "stdafx.h" 
#include "Geotest.h" 
#include "geotestdoc.h" 
#include "MainFrm.h" 
#include "InfoView.h" 
#include "GeotestView.h" 
#include "testview2.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_MAPTOOLS,OnMapTools) 
	ON_UPDATE_COMMAND_UI(ID_VIEW_MAPTOOLS, OnUpdateViewMaptools) 
	ON_COMMAND(ID_VIEW_TREE, OnViewTree) 
	ON_COMMAND(ID_VIEW_GEONAME, OnViewGeoname) 
	ON_UPDATE_COMMAND_UI(ID_VIEW_GEONAME, OnUpdateViewGeoname) 
	//}}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() 
{ 
	// 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 
	} 
 
	//创建MAPNAME对话框   CG_ID_VIEW_MYDIALOGBAR 是对话条的控制ID 
	if (!m_mapname.Create(this, IDD_MAPNAME,CBRS_TOP,CG_ID_VIEW_MYDIALOGBAR)) 
		{ 
			TRACE0("Failed to create dialog bar m_wndMyDialogBar\n"); 
			return -1;		// fail to create 
		}   
	m_mapname.EnableDocking(CBRS_ALIGN_ANY); 
	m_mapToolBar.SetBarStyle(m_mapname.GetBarStyle()| 
		CBRS_HIDE_INPLACE|CBRS_FLYBY|CBRS_TOOLTIPS|CBRS_SIZE_DYNAMIC); 
	 
	//DockControlBar(&m_mapname,AFX_IDW_DOCKBAR_BOTTOM); 
 
/*	if(!m_wndToolBar.Create(this)|| 
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) 
	{ 
		TRACE0("Failed to create  the toolbar of MapToolBar\n"); 
			return -1;   // fail to create the toolbar 
	} 
 
*/ 
	//创建工具栏窗口,装入工具栏所需位图资源, CBRS_TOP|CBRS_BOTTOM|CBRS_TOOLTIPS|CBRS_SIZE_DYNAMIC,IDR_MAPTOOLBAR 
	if(!m_mapToolBar.Create(this)|| 
		!m_mapToolBar.LoadToolBar(IDR_MAPTOOLBAR)) 
	{ 
		TRACE0("Failed to create  the toolbar of MapToolBar\n"); 
			return -1;   // fail to create the toolbar 
	} 
	 
	//设置工具栏风格 
	m_mapToolBar.SetBarStyle(m_mapToolBar.GetBarStyle()| 
		CBRS_HIDE_INPLACE|CBRS_FLYBY|CBRS_TOOLTIPS|CBRS_SIZE_DYNAMIC); 
	m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle()| 
		CBRS_FLYBY|CBRS_TOOLTIPS|CBRS_SIZE_DYNAMIC); 
	    m_mapToolBar.EnableDocking(CBRS_ALIGN_ANY); 
		m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); 
	//设定框架窗口内可以任意停靠工具栏 
	EnableDocking(CBRS_ALIGN_ANY); 
	//设定将控件停靠的位置 
	DockControlBar(&m_mapToolBar,AFX_IDW_DOCKBAR_LEFT); 
	DockControlBar(&m_wndToolBar); 
	 
	//使工具栏浮动在屏幕的左上放 
//	FloatControlBar(&m_mapToolBar,CPoint(0,0)); 
 
	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 
	} 
	//设置状态栏项数 
	static UINT indicators[] =  
	{ 
		ID_SEPARATOR, 
		ID_SEPARATOR, 
		ID_INDICATOR_CAPS, 
		ID_INDICATOR_NUM, 
		ID_INDICATOR_SCRL, 
	}; 
	//设置各项风格 
	m_wndStatusBar.SetPaneInfo(1,ID_SEPARATOR,SBPS_STRETCH,50); 
 
	// 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); 
    RecalcLayout(); 
	//位置排序 
	CRect rect; 
	m_wndToolBar.GetWindowRect(rect); 
	rect.OffsetRect(1,0); 
	DockControlBar(&m_mapname, AFX_IDW_DOCKBAR_TOP,rect);  //靠近TOOLBAR停靠 
 
 
	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 
	cs.style &= ~FWS_ADDTOTITLE ; 
	cs.lpszName = "Geotest"; 
	cs.cx=GetSystemMetrics(SM_CXSCREEN);//得到屏幕的分辨率 
	cs.cy=GetSystemMetrics(SM_CYSCREEN); 
	return TRUE; 
} 
 
//BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, 
/*								  CCreateContext* pContext) 
{ 
	if(m_wndSplitter.CreateStatic(this,1,2)==NULL) 
		return FALSE; 
	m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CGeotestView),CSize(600,600),pContext); 
	m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CInfoView),CSize(100,100),pContext); 
	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::OnUpdateViewMaptools(CCmdUI* pCmdUI)  
{ 
	pCmdUI->SetCheck(m_Checked); 
	pCmdUI->Enable(); 
	 
} 
void CMainFrame ::OnMapTools() 
{ 
	if(m_mapToolBar.IsVisible()) 
	{ShowControlBar(&m_mapToolBar, FALSE, FALSE);m_Checked=FALSE;} 
	else 
	{ShowControlBar(&m_mapToolBar, TRUE, FALSE);m_Checked=TRUE;} 
	RecalcLayout(); 
} 
 
void CMainFrame::OnViewTree()  
{ 
	// TODO: Add your command handler code here 
	/*CLayerTreeDlg dlgLayerTree; 
	dlgLayerTree.m_pMapX = &m_ctrlMapX; 
	dlgLayerTree.DoModal(); 
	*/ 
} 
 
void CMainFrame::OnViewGeoname()  
{ 
	// TODO: Add your command handler code here 
	if(m_mapname.IsVisible()) 
	{ShowControlBar(&m_mapname, FALSE, TRUE);m_CheckedMapName=FALSE;} 
	else 
	{ShowControlBar(&m_mapname, TRUE, TRUE);m_CheckedMapName=TRUE;} 
	RecalcLayout(); 
	 
} 
 
void CMainFrame::OnUpdateViewGeoname(CCmdUI* pCmdUI)  
{ 
	// TODO: Add your command update UI handler code here 
	pCmdUI->SetCheck(m_mapname.IsWindowVisible()); 
	 
} 
 
BOOL CMainFrame::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)  
{ 
	// TODO: Add your specialized code here and/or call the base class 
	rectDefault; 
	dwStyle=WS_HSCROLL|WS_MAXIMIZE; 
	 
 
	 
	return CWnd::Create(lpszClassName, lpszWindowName, WS_HSCROLL|WS_MAXIMIZE, rect, pParentWnd, nID, pContext); 
}