📄 mainfrm.cpp
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "MYFUSION.h"
#include "MainFrm.h"
//#include "ImgOPen.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//全局变量///////////
OperationType NormalStatus = DO_NOTHING;
//选点
double lfptDIBMousex = -1.0f;
double lfptDIBMousey = -1.0f;
//全局函数//////////
void FillSolidRectUser(CDC * pDC, const CRect oldrcDest,const CRect newrcDest,COLORREF bkColor /* = NULL */);
void SetCurrentState();
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_COMMAND(IDM_NAVIGATION, OnNavigation)
ON_COMMAND(IDM_ZOOMINDLG, OnZoomindlg)
ON_UPDATE_COMMAND_UI(IDM_NAVIGATION, OnUpdateNavigation)
ON_UPDATE_COMMAND_UI(IDM_ZOOMINDLG, OnUpdateZoomindlg)
//}}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 indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
NavigationDialog=new CNavigationDialog(this);
ZoomInDlg =new CZoomInDlg(this);
m_bFullScreenMode=FALSE;
CreateBlankDocument = FALSE;
}
CMainFrame::~CMainFrame()
{
if(NavigationDialog != NULL)
{
delete NavigationDialog;
}
if(ZoomInDlg != NULL)
{
delete ZoomInDlg;
}
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::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);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CMDIFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
// 2005.03.04
cs.style = WS_OVERLAPPEDWINDOW | WS_CAPTION | FWS_ADDTOTITLE
| WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX ;
cs.cx = ::GetSystemMetrics(SM_CXMAXIMIZED) ;
cs.cy = ::GetSystemMetrics(SM_CYMAXIMIZED) ;
cs.cx = (int)(0.995*cs.cx);
cs.cy = (int)(0.995*cs.cy);
cs.x = (int)(0.0005*cs.cx);
cs.y = (int)(0.0005*cs.cy);
m_strTitle = "高光谱影像处理与分析";
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// 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::FullScreenModeOn()
{
// available only if there is an active doc
CMDIChildWnd* pChild=MDIGetActive();
// if(!pChild) return;
//Hide Toolbar and Statusbar
m_bToolBarWasVisible=(m_wndToolBar.IsWindowVisible()!=0);
m_wndToolBar.ShowWindow(SW_HIDE);
// m_bStatusBarWasVisible=(m_wndStatusBar.IsWindowVisible()!=0);
// m_wndStatusBar.ShowWindow(SW_HIDE);
// first create the new toolbar
// this will contain the full-screen off button
m_pwndFullScreenBar=new CToolBar;
m_pwndFullScreenBar->Create(this);
m_pwndFullScreenBar->SetBarStyle(m_pwndFullScreenBar->GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
// to look better:
m_pwndFullScreenBar->ModifyStyle(0, TBSTYLE_FLAT);
m_pwndFullScreenBar->EnableDocking(0);
// place the full-screen off button somewhere:
CPoint NavPos;
NavPos.x = AfxGetApp()->GetProfileInt("MAINFRAME","FullScreenBarPosLeft",-1);
NavPos.y = AfxGetApp()->GetProfileInt("MAINFRAME","FullScreenBarPosTop",-1);
int nFullWidth=::GetSystemMetrics(SM_CXSCREEN);
int nFullHeight=::GetSystemMetrics(SM_CYSCREEN);
NavPos.x -= 2; NavPos.y -= 20;
if(NavPos.x<0 || NavPos.y<0 || NavPos.x>=nFullWidth-50 || NavPos.y>=nFullHeight-100 )
{
NavPos.x=20;
NavPos.y=120;
}
FloatControlBar(m_pwndFullScreenBar,NavPos);
// now save the old positions of the main and child windows
GetWindowRect(&m_mainRect);
// remove the caption of the mainWnd:
LONG style=::GetWindowLong(m_hWnd,GWL_STYLE);
style&=~WS_CAPTION;
::SetWindowLong(m_hWnd,GWL_STYLE,style);
int screenx=GetSystemMetrics(SM_CXSCREEN);
int screeny=GetSystemMetrics(SM_CYSCREEN);
// resize:
SetWindowPos(NULL,0,0,screenx,screeny,SWP_NOZORDER);
if(pChild)
{
style=::GetWindowLong(pChild->m_hWnd,GWL_STYLE);
m_bChildMax=(style & WS_MAXIMIZE)?true:false;
}
// note here: m_bMainMax is not needed since m_hWnd only
// changed its caption...
///***************
//Save the Original Menu and set menu to NULL
ASSERT(m_OrgMenu.GetSafeHmenu()==NULL);
CMenu* pOldMenu=GetMenu();
m_OrgMenu.Attach(pOldMenu->Detach());
// SetMenu((CMenu*)NULL);
// and maximize the child window
// it will remove its caption, too.
//pChild->
// this->ShowWindow (SW_SHOWMAXIMIZED);
// style=::GetWindowLong(pChild->m_hWnd,GWL_STYLE);
// style&=~WS_CAPTION;
// ::SetWindowLong(pChild->m_hWnd,GWL_STYLE,style);
//pChild->SetWindowPos (NULL,-5,-5,screenx+5,screeny+5,SWP_NOZORDER);
// pChild->ShowWindow(SW_SHOWMAXIMIZED);
m_bFullScreenMode=true;
}
void CMainFrame::FullScreenModeOff()
{
//Install the menu
ASSERT(m_OrgMenu.GetSafeHmenu()!=NULL);
// SetMenu(&m_OrgMenu);
m_OrgMenu.Detach();
// You can use SaveBarState() in OnClose(),
// so remove the newly added toolbar entirely
// in order SaveBarState() not
// to save its state. That is why I used dynamic
// allocation
CRect NavPos;
m_pwndFullScreenBar->GetWindowRect(&NavPos);
//wirte Navigation Dialog position in REGISTER before quit the system;
AfxGetApp()->WriteProfileInt("MAINFRAME","FullScreenBarPosLeft",NavPos.left);
AfxGetApp()->WriteProfileInt("MAINFRAME","FullScreenBarPosTop",NavPos.top);
delete m_pwndFullScreenBar;
LONG style=::GetWindowLong(m_hWnd,GWL_STYLE);
style|=WS_CAPTION;
::SetWindowLong(m_hWnd,GWL_STYLE,style);
if(m_bToolBarWasVisible)
m_wndToolBar.ShowWindow(SW_SHOW);
if(m_bStatusBarWasVisible)
m_wndStatusBar.ShowWindow(SW_SHOW);
MoveWindow(&m_mainRect);
RecalcLayout();
CMDIChildWnd* pChild=MDIGetActive();
if(pChild)
{
style=::GetWindowLong(pChild->m_hWnd,GWL_STYLE);
style|=WS_CAPTION;
::SetWindowLong(pChild->m_hWnd,GWL_STYLE,style);
// pchild can be NULL if the USER closed all the
// childs during Full Screen Mode:
if(m_bChildMax)
MDIMaximize(pChild);
else MDIRestore(pChild);
}
m_bFullScreenMode=false;
}
void CMainFrame::OnNavigation()
{
BOOL bVisible = ((NavigationDialog->GetStyle() & WS_VISIBLE) != 0);
if(bVisible)
{
NavigationDialog->ShowWindow(SW_HIDE);
NavigationDialog->UpdateWindow();
}
else
{
NavigationDialog->ShowWindow(SW_SHOW);
NavigationDialog->UpdateWindow();
}
}
void CMainFrame::OnZoomindlg()
{
BOOL bVisible = ((ZoomInDlg->GetStyle() & WS_VISIBLE) != 0);
if(bVisible)
{
ZoomInDlg->ShowWindow(SW_HIDE);
ZoomInDlg->UpdateWindow();
}
else
{
ZoomInDlg->ShowWindow(SW_SHOW);
ZoomInDlg->UpdateWindow();
}
}
void CMainFrame::CreateNavDialog()
{
if(NavigationDialog->GetSafeHwnd()==NULL)
{
NavigationDialog->Create(IDD_NAVIGATIONDIALOG,this);
NavigationDialog->ShowWindow(SW_SHOW);
NavigationDialog->UpdateWindow();
}
}
void CMainFrame::CreateZoomInDialog()
{
if(ZoomInDlg->GetSafeHwnd()==NULL)
{
ZoomInDlg->Create(IDD_ZOOMIN_DLG,this);
ZoomInDlg->ShowWindow(SW_SHOW);
ZoomInDlg->UpdateWindow();
}
}
void CMainFrame::OnUpdateZoomindlg(CCmdUI* pCmdUI)
{
BOOL bVisible = ((ZoomInDlg->GetStyle() & WS_VISIBLE) != 0);
pCmdUI->SetCheck(bVisible);
}
void CMainFrame::OnUpdateNavigation(CCmdUI* pCmdUI)
{
BOOL bVisible = ((NavigationDialog->GetStyle() & WS_VISIBLE) != 0);
pCmdUI->SetCheck(bVisible);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -