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

📄 zhinengdlg.cpp

📁 用visual c++6.0编写的 FFT程序
💻 CPP
字号:
// zhinengDlg.cpp : implementation file
//

#include "stdafx.h"
#include "zhineng.h"
#include "zhinengDlg.h"
#include "FFT.h"

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

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CZhinengDlg dialog

CZhinengDlg::CZhinengDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CZhinengDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CZhinengDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CZhinengDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CZhinengDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CZhinengDlg, CDialog)
	//{{AFX_MSG_MAP(CZhinengDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CZhinengDlg message handlers

BOOL CZhinengDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	FFT::myFFT->mainFFT();//////////////2008.12.22李琳

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CZhinengDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CZhinengDlg::OnPaint() 
{

	CPaintDC dc(this); // device context for painting
    int cxIcon = GetSystemMetrics(SM_CXICON);
	int cyIcon = GetSystemMetrics(SM_CYICON);
	CRect rect;
	GetClientRect(&rect);
	int x = (rect.Width() - cxIcon + 1) / 2;
	int y = (rect.Height() - cyIcon + 1) / 2;

	int wide;
	int high;
	wide=rect.right-rect.left;
	high=rect.bottom-rect.top;
	hDC1=::GetDC(m_hWnd);
	HFONT hFont,hOldFont;
	hFont=make_font(hDC1,17,8);
	hOldFont = (HFONT)::SelectObject(hDC1, hFont);
	char szStr[MAXCHAR];
	::SetBkMode(hDC1,TRANSPARENT);	
// 	strcpy(szStr,"Y");
// 	::TextOut(hDC1,rect.left+15,rect.top+30,szStr,strlen(szStr));
// 	strcpy(szStr,"X");
// 	::TextOut(hDC1,rect.right-35,rect.bottom-30,szStr,strlen(szStr));
// 	strcpy(szStr,"∧");
// 	::TextOut(hDC1,rect.left+22,rect.top+25,szStr,strlen(szStr));
// 	strcpy(szStr,">");
// 	::TextOut(hDC1,rect.right-40,rect.bottom-38,szStr,strlen(szStr));
	
	::SelectObject(hDC1, hOldFont);
	::DeleteObject(hFont);
	
	HPEN  hPen, hOldPen;
	hPen = ::CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	hOldPen = (HPEN)::SelectObject(hDC1, hPen);
	
	RECT rcbox1,rcbox2;
	rcbox1.left=rect.left+30;
	rcbox1.top=rect.top+30;
	rcbox1.right=rcbox1.left+490;
	rcbox1.bottom=rect.top+180;

	rcbox2.left=rect.left+30;
	rcbox2.top=rect.top+210;
	rcbox2.right=rcbox2.left+490;
	rcbox2.bottom=rect.top+360;
	HBRUSH hbrgray;
	HBRUSH hbrwhite;
	hbrgray=::CreateSolidBrush(RGB(212,208,208));
	hbrwhite=::CreateSolidBrush(RGB(255,255,255));
	::FillRect(hDC1,&rect,hbrgray);
	::DrawEdge(hDC1,&rcbox1,BDR_RAISEDINNER,BF_RECT);
    ::DrawEdge(hDC1,&rcbox2,BDR_RAISEDINNER,BF_RECT);
	::FillRect(hDC1,&rcbox1,hbrwhite);
	::FillRect(hDC1,&rcbox2,hbrwhite);

	MoveToEx(hDC1,rcbox1.left,rcbox1.bottom,NULL);
	LineTo(hDC1,rcbox1.right,rcbox1.bottom);
	LineTo(hDC1,rcbox1.right,rcbox1.top);
	LineTo(hDC1,rcbox1.left,rcbox1.top);
	LineTo(hDC1,rcbox1.left,rcbox1.bottom);

	MoveToEx(hDC1,rcbox2.left,rcbox2.bottom,NULL);
	LineTo(hDC1,rcbox2.right,rcbox2.bottom);
	LineTo(hDC1,rcbox2.right,rcbox2.top);
	LineTo(hDC1,rcbox2.left,rcbox2.top);
	LineTo(hDC1,rcbox2.left,rcbox2.bottom);

	for (int i=0;i<6;i++)
	{
		MoveToEx(hDC1,rcbox1.left+70*(i+1),rcbox1.bottom,NULL);
		LineTo(hDC1,rcbox1.left+70*(i+1),rcbox1.bottom-5);
	}
	for (i=0;i<6;i++)
	{
		MoveToEx(hDC1,rcbox1.left+70*(i+1),rcbox1.top,NULL);
		LineTo(hDC1,rcbox1.left+70*(i+1),rcbox1.top+5);
	}
	for (int j=0;j<2;j++)
	{
		MoveToEx(hDC1,rcbox1.left,rcbox1.bottom-(j+1)*50,NULL);
		LineTo(hDC1,rcbox1.left+5,rcbox1.bottom-(j+1)*50);
	}
	for (j=0;j<2;j++)
	{
		MoveToEx(hDC1,rcbox1.right,rcbox1.bottom-(j+1)*50,NULL);
		LineTo(hDC1,rcbox1.right-5,rcbox1.bottom-(j+1)*50);
	}
	for (i=0;i<9;i++)
	{
		MoveToEx(hDC1,rcbox2.left+49*(i+1),rcbox2.bottom,NULL);
		LineTo(hDC1,rcbox2.left+49*(i+1),rcbox2.bottom-5);
	}
	for (i=0;i<9;i++)
	{
		MoveToEx(hDC1,rcbox2.left+49*(i+1),rcbox2.top,NULL);
		LineTo(hDC1,rcbox2.left+49*(i+1),rcbox2.top+5);
	}
	for (j=0;j<4;j++)
	{
		MoveToEx(hDC1,rcbox2.left,rcbox2.bottom-(j+1)*30,NULL);
		LineTo(hDC1,rcbox2.left+5,rcbox2.bottom-(j+1)*30);
	}
	for (j=0;j<4;j++)
	{
		MoveToEx(hDC1,rcbox2.right,rcbox2.bottom-(j+1)*30,NULL);
		LineTo(hDC1,rcbox2.right-5,rcbox2.bottom-(j+1)*30);
	}

	::SelectObject(hDC1, hOldPen);
	::DeleteObject(hPen);

// 	MoveToEx(hDC1,rcbox2.left,rcbox2.bottom+FFT::myFFT->ashow[0],NULL);
// 	for (int ia=0;ia<500;ia++)
// 	{
// 		LineTo(hDC1,rcbox2.left+0.98*ia,rcbox2.bottom+FFT::myFFT->ashow[ia+1]*0.98);
// 	}
	if (IsIconic())
	{
// 		CPaintDC dc(this); // device context for painting
// 
		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// 
// 		// Center icon in client rectangle
// 		int cxIcon = GetSystemMetrics(SM_CXICON);
// 		int cyIcon = GetSystemMetrics(SM_CYICON);
// 		CRect rect;
// 		GetClientRect(&rect);
// 		int x = (rect.Width() - cxIcon + 1) / 2;
// 		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);

	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CZhinengDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}
HFONT CZhinengDlg::make_font(HDC hDC, int h, int w, LPCSTR szFace)
{
	HFONT hFont;
	
	hFont = ::CreateFont(
		h, //フォント高さ
		w, //文字幅
		0, //テキストの角度
		0, //ベースラインとx軸との角度
		FW_NORMAL, //フォントの重さ(太さ)
		FALSE, //イタリック体
		FALSE, //アンダーライン
		FALSE, //打ち消し線
		DEFAULT_CHARSET, //文字セット
		OUT_DEFAULT_PRECIS, //出力精度
		CLIP_DEFAULT_PRECIS,//クリッピング精度
		PROOF_QUALITY, //出力品質
		FIXED_PITCH | FF_MODERN,//ピッチとファミリー
		szFace); //書体名
	return hFont;
}

⌨️ 快捷键说明

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