⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainfrm.cpp

📁 此为地球物理中的
💻 CPP
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"

#include "P_R.h"
#include"P_RDoc.h"
#include"globalExt.h"
#include "MainFrm.h"
#include"P_RView.h"
#include"ResaultView.h"

#include"DialogSet.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMainFrame
#include "AppFace.h"

CAppFace g_af;
/*
enum ACTION
{
   DRAWPOINT,
   WORK,
   NULLACTION,
   ClIKLEN
};
ACTION NOWACTION;
HCURSOR m_hMouseCursor;	//鼠标样式
*/
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_WM_SIZE()
	ON_WM_CLOSE()
	ON_COMMAND(ID_PerPoty, OnPerPoty)
	//}}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
	m_bInitSplitter=false;
}

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_wndToolBar2.CreateEx(this, TBSTYLE_FLAT | TBSTYLE_LIST, WS_CHILD | 
	    WS_VISIBLE | CBRS_TOP| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | 
        CBRS_SIZE_DYNAMIC) ||!m_wndToolBar2.LoadToolBar(IDR_TOOLBAR))
	{
	 TRACE0("Failed to create toolbar\n");
	 return -1; 
	}
               m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
               m_wndToolBar2.EnableDocking(CBRS_ALIGN_ANY);
               EnableDocking(CBRS_ALIGN_ANY);
               DockControlBar(&m_wndToolBar);
			   DockControlBar(&m_wndToolBar2);
               //DockControlBarLeftOf(&Bar,&m_wndToolBar1);
			   DockControlBarLeftOf(&m_wndToolBar2,&m_wndToolBar);
  
    // GetViews();
	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 = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE
		| WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_MAXIMIZE;
    
	Skin(_T("sap_af.urf")) ;  //加载皮肤
	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::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{
	//CSplitterWnd m_wndSplitter;
	CRect cr;
	GetWindowRect( &cr );
	
	// Create the main splitter with 1 row and 2 columns
	if ( !m_wndSplitter.CreateStatic( this, 1, 2 ) )
	{
		MessageBox( "Error setting up m_wndSplitter", "ERROR", MB_OK | MB_ICONERROR );
		return FALSE;
	}

	// The views for each pane must be created 
	if ( !m_wndSplitter.CreateView( 0, 0, RUNTIME_CLASS(CP_RView),
	//if ( !m_wndSplitter.CreateView( 0, 0, RUNTIME_CLASS(pContext->m_pNewViewClass),
		CSize(cr.Width()/2-20, cr.Height()), pContext ) )
	{
		MessageBox( "Error setting up splitter view", "ERROR", MB_OK | MB_ICONERROR );
		return FALSE;
	}

	if ( !m_wndSplitter.CreateView( 0, 1, RUNTIME_CLASS(ResaultView),
	//if ( !m_wndSplitter.CreateView( 0, 1, RUNTIME_CLASS(CP_RView),
		CSize(cr.Width()/2+20, cr.Height()), pContext ) )
	{
		MessageBox( "Error setting up splitter view", "ERROR", MB_OK | MB_ICONERROR );
		return FALSE;
	}

	m_bInitSplitter = true;//分割条是否创建成功
	return TRUE;
	//return CFrameWnd::OnCreateClient(lpcs, pContext);
}

void CMainFrame::OnSize(UINT nType, int cx, int cy) 
{
	CFrameWnd::OnSize(nType, cx, cy);
	
    CRect cr;
    GetWindowRect(&cr);

    if (  m_bInitSplitter && nType != SIZE_MINIMIZED )
    {
        m_wndSplitter.SetRowInfo( 0, cy, 0 );
        m_wndSplitter.SetColumnInfo( 0, cr.Width() / 2-20, 50);
        m_wndSplitter.SetColumnInfo( 1, cr.Width() / 2+20, 50);

        m_wndSplitter.RecalcLayout();
    }	
}
void CMainFrame::DockControlBarLeftOf(CToolBar* Bar, CToolBar* LeftOf)
		//此一段程序可以使toolbar停靠在一起
{
		CRect rect;
		DWORD dw;
		UINT n;
		// get MFC to adjust the dimensions of all docked ToolBars
		// so that GetWindowRect will be accurate
		RecalcLayout(TRUE);
		LeftOf->GetWindowRect(&rect);
		rect.OffsetRect(1,0);
		dw=LeftOf->GetBarStyle();
		n = 0;
		n = (dw&CBRS_ALIGN_TOP) ? AFX_IDW_DOCKBAR_TOP : n;
		n = (dw&CBRS_ALIGN_BOTTOM && n==0) ? AFX_IDW_DOCKBAR_BOTTOM : n;
		n = (dw&CBRS_ALIGN_LEFT && n==0) ? AFX_IDW_DOCKBAR_LEFT : n;
		n = (dw&CBRS_ALIGN_RIGHT && n==0) ? AFX_IDW_DOCKBAR_RIGHT : n;
		DockControlBar(Bar,n,&rect);
} 
void CMainFrame::GetViews()
{
//Code beginning
 //get the right view (the list view)
 CWnd* pWnd = m_wndSplitter.GetPane(0, 1);
 //cast the right view to the CFView type where F is 
 //the name of Application and store it in list variable
ResaultView* list= DYNAMIC_DOWNCAST(ResaultView, pWnd);
 //get the left view (the tree view)
 pWnd = m_wndSplitter.GetPane(0, 0);
 //cast it to CLeftView type and store it in tree variable
 CP_RView * tree = DYNAMIC_DOWNCAST(CP_RView, pWnd);
 //store the list view in the m_listview variable 
 //(member of CLeftView class)
  //tree->m_treeview=list; 
 //tree->m_listview=list;
 //store the tree view in the m_treeview 
 //variable (member of CFView class)
  //list->m_listview=tree;
 //end of code
}
void CMainFrame::Skin(LPCTSTR strSkinFile)
{
	char path[256];
	memset(path,0,256) ;
	GetModuleFileName(NULL,path,256) ;
	char * p = strrchr(path,'\\') ;
	if(!p) return  ;
	strcpy(p,"\\\0\0");
	strcat(p,strSkinFile);
	g_af.Start(path)      ;

	//m_MyBar.m_wndOutlookBar.SkinReset() ;

	//for(int i=0;i<4;i++)
	//	m_AutoHideBar[i].SkinReset() ;
}

void CMainFrame::OnClose() 
{
    g_af.Remove();
	
		if(g_Terrain!=NULL)
	   delete []g_Terrain;
	if(g_Ray!=NULL)
	   delete []g_Ray;

	CFrameWnd::OnClose();

}

void CMainFrame::OnPerPoty()
{
   DialogSet dialog;

	if(dialog.DoModal()==IDOK)
		Invalidate(true);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -