?? message.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 + -