anyman of mine意思:C++编程高手进(MFC)

来源:百度文库 编辑:高考问答 时间:2024/04/29 05:30:31
我想编个程序(要用到C++中的MFC)请个位大虾帮小弟设计下,只要设计一个开始时的一个对话框界面,界面如下:
求最短路径
1。第一种方法计算最短路径
2。第二种方法计算最短路径
3。第三种方法计算最短路径
4。第四种方法计算最短路径
(按1-4选择方法, 按0退出)
也就是事先以编好了4种程序代码,按1-4后执行其中一种代码。各位大虾在设计时可以随便用4个简单的程序代码代替下。小弟在这谢谢了
我的邮箱 pvlking@126.com,一开始的MFC创建也简单的说下哈(就是要插入什么控件,一开始的步骤)

留下邮箱!我发给你哦

下面是一部分...

// TempDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Temp.h"
#include "TempDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTempDlg dialog

CTempDlg::CTempDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTempDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTempDlg)
m_strLabel = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CTempDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTempDlg)
DDX_Text(pDX, IDC_STATIC_ONE, m_strLabel);
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CTempDlg, CDialog)
//{{AFX_MSG_MAP(CTempDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_KEYDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTempDlg message handlers

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

// 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
m_strLabel="求最短路径\n1。第一种方法计算最短路径\n2。第二种方法计算最短路径\n3。第三种方法计算最短路径\n4。第四种方法计算最短路径\n(按1-4选择方法, 按0退出)";
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}

// 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 CTempDlg::OnPaint()
{
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 CTempDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}

BOOL CTempDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message == WM_KEYDOWN)
SendMessage(WM_KEYDOWN,pMsg->wParam,pMsg->lParam);
// if no keystroke check if the message will be handled by our dialog
if(IsDialogMessage(pMsg))
return TRUE;
else
return CDialog::PreTranslateMessage(pMsg);
}

void CTempDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
if (nChar=='0')
{
CDialog::OnCancel();
return;
}
if (nChar>'0' && nChar<'5' )
{
CString temp;
temp.Format("you select %c",nChar);
MessageBox(temp);
}

}