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

📄 mainfrm.cpp

📁 这是一款蛮COOL的图像处理系统
💻 CPP
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "QuickImage.h"

#include "MainFrm.h"
#include "DirFrm.h"
#include "ImgFrm.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMainFrame

IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code !
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

static UINT indicators[] =
{
	ID_SEPARATOR,           // status line indicator
	ID_SEPARATOR,
	ID_SEPARATOR,
//	ID_INDICATOR_CAPS,
//	ID_INDICATOR_NUM,
//	ID_INDICATOR_SCRL,
};

/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
//	m_muToolBars[0] = FALSE;
	
}

CMainFrame::~CMainFrame()
{
}

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
	}

/*	if (!m_tbMap.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_tbMap.LoadToolBar(IDR_TB_MAP))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}
	m_tbMap.EnableDocking(CBRS_ALIGN_ANY);
*/	// 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);

	m_wndStatusBar.SetPaneInfo(1, ID_SEPARATOR, SBPS_NORMAL, 150);
	m_wndStatusBar.SetPaneInfo(2, ID_SEPARATOR, SBPS_NORMAL, 80);
	SetStatusText(0);
//	ShowControlBar(&m_tbMap,FALSE,FALSE);
	CenterWindow();

	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
	CRect rcDesktop;
	::GetWindowRect(::GetDesktopWindow(),&rcDesktop);
	cs.cx=rcDesktop.Width();
	cs.cy=rcDesktop.Height()-30;

	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


BOOL CMainFrame::UpdateUIs(BOOL bActivate, const CWnd* pActivateWnd, const CWnd* pDeactivateWnd)
{
/*	DWORD dwStyle = m_tbMap.GetBarStyle();
	UINT nDockBarID = 0;
	nDockBarID = (dwStyle & CBRS_ALIGN_TOP) ? AFX_IDW_DOCKBAR_TOP : nDockBarID;
	nDockBarID = (dwStyle & CBRS_ALIGN_BOTTOM && nDockBarID==0) ? AFX_IDW_DOCKBAR_BOTTOM : nDockBarID;
	nDockBarID = (dwStyle & CBRS_ALIGN_LEFT && nDockBarID==0) ? AFX_IDW_DOCKBAR_LEFT : nDockBarID;
	nDockBarID = (dwStyle & CBRS_ALIGN_RIGHT && nDockBarID==0) ? AFX_IDW_DOCKBAR_RIGHT : nDockBarID;
//Modify Toolbar	
	if(NULL == pActivateWnd)
	{
		m_tbMap.ShowWindow(SW_HIDE);
		m_muToolBars[0] = FALSE;
		RecalcLayout();	
		return TRUE;
	}
	else if(pActivateWnd->IsKindOf(RUNTIME_CLASS(CDirFrame)))
	{
		m_tbMap.ShowWindow(SW_HIDE);
		m_muToolBars[0] = TRUE;
	}
	else if(pActivateWnd->IsKindOf(RUNTIME_CLASS(CImgFrame)))
	{
		m_tbMap.ShowWindow(SW_SHOW);
		DockControlBar(&m_tbMap, nDockBarID);
		m_muToolBars[0] = TRUE;
	}
	else
	{
		m_tbMap.ShowWindow(SW_HIDE);
		m_muToolBars[0] = FALSE;
	}
	RecalcLayout();	
*/
/////////////Modify Menu	
	return TRUE;
}

int CMainFrame::FindMenuItem(const CMenu *Menu, LPCTSTR MenuString)
{
   ASSERT(Menu);
   ASSERT(::IsMenu(Menu->GetSafeHmenu()));

   int count = Menu->GetMenuItemCount();
   for (int i = 0; i < count; i++)
   {
      CString str;
      if (Menu->GetMenuString(i, str, MF_BYPOSITION) &&
         (strcmp(str, MenuString) == 0))
         return i;
   }

   return -1;
}

void CMainFrame::SetStatusText(int iPane, LPCTSTR lpszText)
{
//	ASSERT(iPane > -1 && m_wndStatusBar
	if(NULL == lpszText)
	{
		m_wndStatusBar.SetPaneText(1, _T("Image Size: "));
		m_wndStatusBar.SetPaneText(2, _T("Zoom: "));
	}
	else
	{
		m_wndStatusBar.SetPaneText(iPane, lpszText); 
	}
}

⌨️ 快捷键说明

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