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

📄 message.h

📁 在程序启动时
💻 H
字号:
#include "resource.h"
#include "Hanoi.h"
#include "Brick.h"
#include "List.h"

//////////////////////////////////////////////////////////////////////

extern void move(CList* a, int n, CList* b, HWND hWnd);
extern void hanoi(int n, CList* x, CList* y, CList* z, HWND hWnd);
extern HINSTANCE hInst;
extern CList x, y, z;

//////////////////////////////////////////////////////////////////////

struct MSGMAP_ENTRY
{
	UINT nMessage;
	LONG (*pfn)(HWND, UINT, WPARAM, LPARAM);
};

#define dim(x)  (sizeof(x)/sizeof(x[0]))

//////////////////////////////////////////////////////////////////////

struct MSGMAP_ENTRY _messageEntry[] =	//消息映射
{
	WM_CREATE,	OnCreate,
	WM_PAINT,	OnPaint,
	WM_DESTROY,	OnDestroy,
	WM_COMMAND,	OnCommand,
	WM_LBUTTONDOWN, OnLButtonDown,
	WM_RBUTTONDOWN, OnRButtonDown,
};

struct MSGMAP_ENTRY _commandEntry[] =
{
	IDM_QUIT,		OnQuit,
	IDM_HELP,		OnHelp,
	IDM_ABOUT,		OnAbout,
	IDM_SRART,		OnStart,
};



//////////////////////////////////////////////////////////////////////

LONG OnCommand(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int i;

	for(i = 0; i<dim(_commandEntry); i++)
	{
		if(LOWORD(wParam) == _commandEntry[i].nMessage)
			return ((*_commandEntry[i].pfn)(hWnd, message, wParam, lParam));
	}

	return DefWindowProc(hWnd, message, wParam, lParam);
}

//////////////////////////////////////////////////////////////////////

LONG OnCreate(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	x.CreateTower();
	y.SetNextRect(260, 400, 460, 408);
	z.SetNextRect(510, 400, 710, 408);
	return 0;
}

//////////////////////////////////////////////////////////////////////

LONG OnPaint(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{	
	HDC hdc;
	PAINTSTRUCT ps;
	hdc = BeginPaint(hWnd, &ps);

	x.OnDraw(hWnd);		//描画tower块
	y.OnDraw(hWnd);
	z.OnDraw(hWnd);

	EndPaint(hWnd, &ps);
	return 0;
}

//////////////////////////////////////////////////////////////////////

LONG OnDestroy(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	PostQuitMessage(0);
	return 0;
}

//////////////////////////////////////////////////////////////////////

LONG OnLButtonDown(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	POINT pt;
	pt.x = LOWORD(lParam);
	pt.y = HIWORD(lParam);
			
	return 0;
}

//////////////////////////////////////////////////////////////////////

LONG OnRButtonDown(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	POINT pt;
	pt.x = LOWORD(lParam);
	pt.y = HIWORD(lParam);

	return 0;
}

//////////////////////////////////////////////////////////////////////

LONG OnHelp(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	return 0;
}

//////////////////////////////////////////////////////////////////////

LONG OnQuit(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	PostQuitMessage(0);
	return 0;
}

//////////////////////////////////////////////////////////////////////

LONG OnAbout(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	return 0;
}

//////////////////////////////////////////////////////////////////////

LONG OnStart(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	CreateThread(NULL,
				 0,
				 (LPTHREAD_START_ROUTINE)ThreadHanoi,
				 (PVOID)hWnd,
				 0,
				 &m_dwThread);
	return 0;
}

//////////////////////////////////////////////////////////////////////

DWORD ThreadHanoi(PVOID param)
{
	hanoi(15, &x, &y, &z, (HWND)param);
	return 0;
}

//////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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