level 6
文刀2鸟
楼主
俺终于把c++的五子棋程序改写成windowsAPI的了,模拟的字符模式的程序,没有使用任何绘图功能,因此,界面全是字符的,在vc6.0中我一共做了以下几步:1、新建一个新的工程,选择win32 Application,工程框中输入:5zq点完成。2、在工程菜单-----〉设置---------〉link 在object/lib 模块中加入:winmm.lib,以便支持PlaySound()函数。3、新建:C++ Source File,加入工程:5zq中,文件框中输入:5zq点结束4、在5zq.cpp中输入下面的内容:#include
#define BUFFER(x,y) *(pBuffer + y * cxBuffer + x )
#define CHESSNULL 0 //没有棋子#
define CHESS1 'O'//一号玩家的棋子#define CHESS2 'X'//二号玩家的棋子#define CHESSBOARDCROSS '.'#define CROSSRU CHESSBOARDCROSS /*右上角点*/#define CROSSLU CHESSBOARDCROSS /*左上角点*/#define CROSSLD CHESSBOARDCROSS /*左下角点*/#define CROSSRD CHESSBOARDCROSS /*右下角点*/#define CROSSL CHESSBOARDCROSS /*左边*/#define CROSSR CHESSBOARDCROSS /*右边*/#define CROSSU CHESSBOARDCROSS /*上边*/#define CROSSD CHESSBOARDCROSS /*下边*/#define CROSS CHESSBOARDCROSS /*十字交叉点*/#define WINTRUE 1#define WINFALSE 0 LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow){static TCHAR szAppName[]=TEXT("5zq");HWND hwnd;MSG msg;WNDCLASS wndclass;wndclass.style=CS_HREDRAW|CS_VREDRAW;wndclass.lpfnWndProc=WndProc;wndclass.cbClsExtra=0;wndclass.cbWndExtra=0;wndclass.hInstance=hInstance;wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);wndclass.lpszMenuName=NULL;wndclass.lpszClassName=szAppName;if(!RegisterClass(&wndclass)){MessageBox(NULL,TEXT("This program requires Windowsd NT!"),szAppName,MB_ICONERROR);return 0;}hwnd=CreateWindow(szAppName,TEXT("5zq Program"),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);ShowWindow(hwnd,iCmdShow);UpdateWindow(hwnd);while(GetMessage(&msg,NULL,0,0)){TranslateMessage(&msg);DispatchMessage(&msg);}return msg.wParam;}LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2007年09月05日 13点09分
1
#define BUFFER(x,y) *(pBuffer + y * cxBuffer + x )
#define CHESSNULL 0 //没有棋子#
define CHESS1 'O'//一号玩家的棋子#define CHESS2 'X'//二号玩家的棋子#define CHESSBOARDCROSS '.'#define CROSSRU CHESSBOARDCROSS /*右上角点*/#define CROSSLU CHESSBOARDCROSS /*左上角点*/#define CROSSLD CHESSBOARDCROSS /*左下角点*/#define CROSSRD CHESSBOARDCROSS /*右下角点*/#define CROSSL CHESSBOARDCROSS /*左边*/#define CROSSR CHESSBOARDCROSS /*右边*/#define CROSSU CHESSBOARDCROSS /*上边*/#define CROSSD CHESSBOARDCROSS /*下边*/#define CROSS CHESSBOARDCROSS /*十字交叉点*/#define WINTRUE 1#define WINFALSE 0 LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow){static TCHAR szAppName[]=TEXT("5zq");HWND hwnd;MSG msg;WNDCLASS wndclass;wndclass.style=CS_HREDRAW|CS_VREDRAW;wndclass.lpfnWndProc=WndProc;wndclass.cbClsExtra=0;wndclass.cbWndExtra=0;wndclass.hInstance=hInstance;wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);wndclass.lpszMenuName=NULL;wndclass.lpszClassName=szAppName;if(!RegisterClass(&wndclass)){MessageBox(NULL,TEXT("This program requires Windowsd NT!"),szAppName,MB_ICONERROR);return 0;}hwnd=CreateWindow(szAppName,TEXT("5zq Program"),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);ShowWindow(hwnd,iCmdShow);UpdateWindow(hwnd);while(GetMessage(&msg,NULL,0,0)){TranslateMessage(&msg);DispatchMessage(&msg);}return msg.wParam;}LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)