使用WIN32API连接窗口
首先,我弄个主窗口出来,没有用到MFC,直接调用API函数实现,先看看代码吧:
///////////////////////////////////////
//
// 主函数:扫雷
//
///////////////////////////////////////
#include < windows.h >
#include < stdio.h >
#include " DrawMap.h "//见下文
#include " def.h "
int m = 10 , n = 10 ;
int map[MAX_X][MAX_Y];
int Global_x[MAX_X], Global_y[MAX_Y];
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
WINGDIAPI BOOL WINAPI MoveToEx(HDC hdc, int x, int y, LPPOINT lppt);// 移动当前画笔的位置
WINGDIAPI BOOL WINAPI LineTo(HDC hdc, int x, int y); // 用来画直线的函数
WINGDIAPI HPEN WINAPI CreatePen( int iStyle, int cWidth, COLORREF color);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
init(); // 初始化数组(地雷分布
int x_position, y_position, x_size, y_size;
set_position_size( & x_position, & y_position, & x_size, & y_size);static TCHAR szAppName[] = TEXT ( " MainWin " ) ;
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 Windows NT! " ),
szAppName, MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindow (szAppName, // window class name
TEXT ( " 扫雷游戏――The ClearMines Game " ), // window caption
WS_OVERLAPPED |
WS_CAPTION |
WS_SYSMENU |
WS_MINIMIZEBOX, // window style
x_position, // initial x position
- <script type="text/java script">BAIDU_CLB_fillSlot("771048");
- 点击复制链接 与好友分享! 回本站首页
<script> function copyToClipBoard(){ var clipBoardContent=document.title + '\r\n' + document.location; clipBoardContent+='\r\n'; window.clipboardData.setData("Text",clipBoardContent); alert("恭喜您!复制成功"); }<script type="text/java script" id="bdshare_js" data="type=tools&uid=12732"> <script type="text/java script" id="bdshell_js"> <script type="text/java script"> var bds_config = {'snsKey':{'tsina':'2386826374','tqq':'5e544a8fdea646c5a5f3967871346eb8'}}; document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js cdnversion=" + Math.ceil(new Date()/3600000)