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

📄 acs.cpp

📁 蚁群算法是解决电力调配系统和商场供货系统问题的有效算法,这里提供了一种蚁群算法,供大家参考
💻 CPP
字号:
// acs.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "acs.h"
#include "MainFrm.h"
#include "acsDoc.h"
#include "acsView.h"
#include "Splash.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAcsApp
BEGIN_MESSAGE_MAP(CAcsApp, CWinApp)
	ON_COMMAND(CG_IDS_TIPOFTHEDAY, ShowTipOfTheDay)
	//{{AFX_MSG_MAP(CAcsApp)
	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
	// Standard file based document commands
	ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
	ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAcsApp construction

CAcsApp::CAcsApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CAcsApp object

CAcsApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CAcsApp initialization

BOOL CAcsApp::InitInstance()
{
	// CG: The following block was added by the Splash Screen component.\	{\		CCommandLineInfo cmdInfo;\		ParseCommandLine(cmdInfo);\
\		CSplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash);\	}
	AfxEnableControlContainer();
#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));
	LoadStdProfileSettings();  // Load standard INI file options (including MRU)
	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(CAcsDoc),
		RUNTIME_CLASS(CMainFrame),       // main SDI frame window
		RUNTIME_CLASS(CAcsView));
	AddDocTemplate(pDocTemplate);
	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);
	// Dispatch commands specified on the command line
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;
	// The one and only window has been initialized, so show and update it.
	m_pMainWnd->ShowWindow(SW_SHOW);
	m_pMainWnd->UpdateWindow();
	//设置应用程序窗口的标题
	m_pMainWnd->SetWindowText("蚂蚁群落系统(Ant Colony System)");
	m_pMainWnd->CenterWindow();
	// CG: This line inserted by 'Tip of the Day' component.
	Sleep(2000);
	//显示简单使用帮助信息
	ShowTipAtStartup();
	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// 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:
	//声明两个电子邮件显示区域,
	RECT m_pRectLink;
	RECT m_pSecondLink;
	//{{AFX_MSG(CAboutDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	//}}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)
	ON_WM_MOUSEMOVE()
	ON_WM_LBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CAcsApp::OnAppAbout()
{
	CAboutDlg aboutDlg;
	aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CAcsApp message handlers
BOOL CAcsApp::PreTranslateMessage(MSG* pMsg)
{
	// CG: The following lines were added by the Splash Screen component.	if (CSplashWnd::PreTranslateAppMessage(pMsg))		return TRUE;	return CWinApp::PreTranslateMessage(pMsg);
}
BOOL CAboutDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	//将静态文本的坐标放在m_pRectLink中
	GetDlgItem(IDC_LINK1)->GetWindowRect(&m_pRectLink);
	//将屏幕坐标转换为客户坐标
	ScreenToClient(&m_pRectLink);
	GetDlgItem(IDC_LINK2)->GetWindowRect(&m_pSecondLink);
	ScreenToClient(&m_pSecondLink);
	return TRUE;  
}
////////////////////////
//响应鼠标移动的消息
////////////////////////
void CAboutDlg::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	if(point.x>m_pRectLink.left && point.x < m_pRectLink.right &&
		point.y>m_pRectLink.top && point.y <m_pRectLink.bottom)
	{
		HCURSOR hCursor;
		hCursor = AfxGetApp()->LoadCursor(IDC_HAND);
		//将鼠标设置成小手状
		SetCursor(hCursor);
	}
		if(point.x>m_pSecondLink.left && point.x < m_pSecondLink.right &&
		point.y>m_pSecondLink.top && point.y <m_pSecondLink.bottom)
		{
		HCURSOR hCursor;
		hCursor = AfxGetApp()->LoadCursor(IDC_HAND);
		//将鼠标设置成小手状
		SetCursor(hCursor);
		}
	CDialog::OnMouseMove(nFlags, point);
}

////////////////////////////////////////////////////////
//启动IE默认的发送邮件程序,给鼠标指定区域内的地址发邮件
////////////////////////////////////////////////////////
void CAboutDlg::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	if(point.x>m_pRectLink.left && point.x < m_pRectLink.right &&
		point.y>m_pRectLink.top && point.y <m_pRectLink.bottom)
	{
		if(nFlags == MK_LBUTTON)
		{
		ShellExecute(0,NULL,"mailto:chenyb3@263.net",NULL,NULL,SW_NORMAL);
		}
	}

	if(point.x>m_pSecondLink.left && point.x < m_pSecondLink.right &&
		point.y>m_pSecondLink.top && point.y <m_pSecondLink.bottom)
	{
		if(nFlags == MK_LBUTTON)
		{
			//ShellExecute(0,NULL,"http://www.hdpu.edu.cn",NULL,NULL,SW_NORMAL);
			ShellExecute(0,NULL,"mailto:huohy221@sina.com",NULL,NULL,SW_NORMAL);
		}
	}
	CDialog::OnLButtonDown(nFlags, point);
}

void CAcsApp::ShowTipAtStartup(void)
{
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);
	if (cmdInfo.m_bShowSplash)
	{
		CTipDlg dlg;
		if (dlg.m_bStartup)
			dlg.DoModal();
	}
}
/////////////////////////////////////
//响应菜单命令,显示使用帮助信息
////////////////////////////////////
void CAcsApp::ShowTipOfTheDay(void)
{
	CTipDlg dlg;
	dlg.DoModal();

}

⌨️ 快捷键说明

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