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

📄 mainfrm.cpp

📁 主要是应用VC进行傅立叶变换和反变换的程序
💻 CPP
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "bmpDemo.h"

#include "MainFrm.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)
	ON_COMMAND_EX(CG_ID_VIEW_MYDIALOGBAR, OnBarCheck)
	ON_UPDATE_COMMAND_UI(CG_ID_VIEW_MYDIALOGBAR, OnUpdateControlBarMenu)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_WM_SIZE()
	ON_COMMAND(ID_SETTING, OnSetting)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
//	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_SEPARATOR,
	ID_SEPARATOR,
	ID_SEPARATOR,
	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 (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_wToolBar.CreateEx(this,TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED) ||
		!m_wToolBar.LoadToolBar(IDR_TOOLBAR1))
	{
		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);

	m_wToolBar.SetWindowText("图象工具栏1");
//	m_wToolBar.GetToolBarCtrl().ModifyStyle(WS_SYSMENU,0);
	m_wToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wToolBar,AFX_IDW_DOCKBAR_RIGHT);
	ShowControlBar(&m_wToolBar,FALSE,FALSE);
	int nColumns = 2;
	int nCount = m_wToolBar.GetToolBarCtrl().GetButtonCount();
	for (int i = 0; i < nCount; i++)
	{
		UINT nStyle = m_wToolBar.GetButtonStyle(i);
		BOOL bWrap = (((i + 1) % nColumns) == 0);
		if (bWrap)
			nStyle |= TBBS_WRAPPED;
		else
			nStyle &= ~TBBS_WRAPPED;
//		nStyle|=TBBS_CHECKBOX;
		m_wToolBar.SetButtonStyle(i, nStyle);
//		m_wToolBar.SetButtonStyle(i,TBBS_CHECKBOX);
	}

	// TODO: Add a menu item that will toggle the visibility of the	// dialog bar named "My Dialog Bar":	//   1. In ResourceView, open the menu resource that is used by	//      the CMainFrame class	//   2. Select the View submenu	//   3. Double-click on the blank item at the bottom of the submenu	//   4. Assign the new item an ID: CG_ID_VIEW_MYDIALOGBAR	//   5. Assign the item a Caption: My Dialog Bar	// TODO: Change the value of CG_ID_VIEW_MYDIALOGBAR to an appropriate value:	//   1. Open the file resource.h	// CG: The following block was inserted by the 'Dialog Bar' component/*	{		// Initialize dialog bar m_wndMyDialogBar		if (!m_wndMyDialogBar.Create(this, CG_IDD_MYDIALOGBAR,			CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_HIDE_INPLACE,			CG_ID_VIEW_MYDIALOGBAR))		{			TRACE0("Failed to create dialog bar m_wndMyDialogBar\n");			return -1;		// fail to create		}		m_wndMyDialogBar.EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);		EnableDocking(CBRS_ALIGN_ANY);		DockControlBar(&m_wndMyDialogBar);	}*/
	UINT nid;
	UINT nStyle;
	int nWidth;
	CDC *pDC=m_wndStatusBar.GetDC();
	CFont *pFont=pDC->GetCurrentFont();
	LOGFONT font;
	pFont->GetLogFont(&font);
	int width=font.lfWidth*5;
	m_wndStatusBar.GetPaneInfo(3,nid,nStyle,nWidth );
	m_wndStatusBar.SetPaneInfo(3,nid,nStyle,width);
	width=font.lfWidth*15;
	m_wndStatusBar.GetPaneInfo(2,nid,nStyle,nWidth );
	m_wndStatusBar.SetPaneInfo(2,nid,nStyle,width);

	CBmpDemoApp *app=(CBmpDemoApp *)AfxGetApp();
	app->m_EditDialog.Create(IDD_EDITDIALOG,this);
	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

	cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE
		| WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_MAXIMIZE;
	cs.style&= ~FWS_ADDTOTITLE;

	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::OnSize(UINT nType, int cx, int cy) 
{
	CMDIFrameWnd::OnSize(nType, cx, cy);
	CBmpDemoApp *app=(CBmpDemoApp *)AfxGetApp();
	CRect r;
	GetClientRect(&r);
	ClientToScreen(&r);
	if(!app->m_EditDialog.IsWindowVisible()&&app->m_ViewEditTool)
	{
		app->m_EditDialog.SetWindowPos(&wndTop,r.left+10,r.top+50,100,100,SWP_NOSIZE);
		app->m_EditDialog.ShowWindow(SW_SHOW);
	}

	// TODO: Add your message handler code here
}

void CMainFrame::OnSetting() 
{
	// TODO: Add your command handler code here
	CBmpDemoApp *app=(CBmpDemoApp *)AfxGetApp();
	BOOL OldFlag=app->m_ViewToolBar1;
	BOOL OldEditFlag=app->m_ViewEditTool;
	if(app->m_SettingDialog.DoModal()==IDOK)
	{
		if(!m_wToolBar.IsWindowVisible() &&\
			app->m_ViewToolBar1  &&  \
			GetActiveFrame()!=this)
		{
			DockControlBar(&m_wToolBar,AFX_IDW_DOCKBAR_RIGHT);
			ShowControlBar(&m_wToolBar,TRUE,FALSE);
		}

		else if(m_wToolBar.IsWindowVisible() &&\
			!app->m_ViewToolBar1)
		{
			ShowControlBar(&m_wToolBar,FALSE,FALSE);
		}
		if(!app->m_EditDialog.IsWindowVisible()&&\
			app->m_ViewEditTool )
		{
			app->m_EditDialog.ShowWindow(SW_SHOW);
		}
		else if(app->m_EditDialog.IsWindowVisible()&&\
			!app->m_ViewEditTool)
		{
			app->m_EditDialog.ShowWindow(SW_HIDE);
		}
	}
	else
	{
		app->m_ViewToolBar1=OldFlag;
		app->m_ViewEditTool=OldEditFlag;
	}
}

void CMainFrame::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	
	// Do not call CMDIFrameWnd::OnPaint() for painting messages
}

⌨️ 快捷键说明

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