home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Boston 2
/
boston-2.iso
/
WINDOWS
/
GAMES
/
MINES
/
MINES.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-12-01
|
20KB
|
753 lines
/************************************************************************/
/* A N N O T A T E */
/************************************************************************/
/*...vMines:0:*/
/*...vMines\46\def:0:*/
/*...vMines\46\rc:0:*/
/*...vMines\46\dlg:0:*/
/*...vmines\46\h:0:*/
/*...sInclude Files:0:*/
/************************************************************************/
/* I N C L U D E F I L E S */
/************************************************************************/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#define NOMINMAX
#include <windows.h>
#include "mines.h"
/*...e*/
/*...sVariables:0:*/
/************************************************************************/
/* E X T E R N A L V A R I A B L E S */
/************************************************************************/
typedef struct {
int dummy ;
} SETUPDATA ;
SETUPDATA SetUpData ;
HANDLE hInst ; /* Instance handle */
HANDLE hAccel ; /* Accelerator table handle */
HWND hWnd ;
char out[100] ; /* Debugging variable */
char szAppName[]="Mines" ; /* Application Name */
char szProfile[]="Number" ;
char szChildAppName[]=
"ChildMines" ;
typedef struct
{
RECT rect ;
WORD mine ;
} MINE_STRUCT ;
#define MAX_X_MINES 16
#define MAX_Y_MINES 16
MINE_STRUCT minefield[MAX_X_MINES][MAX_Y_MINES] ; /* The Minefield */
#define NO_MINE 0x0000
#define MINE 0x8000
#define VISITED 0x0300
#define THINK_OK 0x0200
#define THINK_MINE 0x0100
#define NOT_SURE 0x0000
#define INV_MINE 0x0400
#define INV_OK 0x0500
#define PAINT_MASK 0x0700
#define INC_THINK 0x0100
#define MAX_THINK 0x0200
#define NOT_VISITED 0x0000
#define FILLED 0x2000
#define HERE 0x1000
#define HERE_MASK 0xEFFF
#define MINES_AROUND 0x000F
WORD NoMines = 30 ;
BOOL InGame = FALSE ;
#define WM_CREATE_MINES WM_USER+1
#define WM_NEW_GAME WM_CREATE_MINES+1
#define WM_HIT_MINE WM_NEW_GAME+1
#define WM_REACHED_END WM_HIT_MINE+1
#define WM_SHOW_MINES WM_REACHED_END+1
#define WM_SET_NO_OF_MINES WM_SHOW_MINES+1
int px,py ; /* player coordinates */
/*...e*/
/*...sCountMines\40\\41\\9\Count the mines around a single point:0:*/
WORD CountMines (int x, int y)
{
int i,j,total = 0 ;
if ( minefield[x][y].mine & MINE )
return (0) ;
for ( i = -1 ; i < 2 ; i++ )
for ( j = -1 ; j < 2 ; j++ )
if ( (x+i) >= 0 && (x+i) < MAX_X_MINES &&
(y+j) >= 0 && (y+j) < MAX_Y_MINES && !(i == 0 && j == 0) )
if ( minefield[x+i][y+j].mine & MINE )
total++ ;
return (total) ;
}
/*...e*/
/*...sAmINearby\40\\41\\9\\9\Return TRUE if I am nearby:0:*/
BOOL AmINearby (int x, int y)
{
int i,j,total = 0 ;
for ( i = -1 ; i < 2 ; i++ )
for ( j = -1 ; j < 2 ; j++ )
if ( (x+i) >= 0 && (x+i) < MAX_X_MINES &&
(y+j) >= 0 && (y+j) < MAX_Y_MINES && !(i == 0 && j == 0) )
if ( minefield[x+i][y+j].mine & HERE )
return (TRUE) ;
return (FALSE) ;
}
/*...e*/
/*...sShowAsMany\40\\41\\9\Show as many of the mines as I can from a certain point:0:*/
BOOL ShowAsMany (HWND hWnd, int x, int y)
{
int i,j ;
if ( (minefield[x][y].mine & MINES_AROUND) || (minefield[x][y].mine & MINE) )
return (FALSE) ;
for ( i = -1 ; i < 2 ; i++ )
for ( j = -1 ; j < 2 ; j++ )
if ( ((x+i) >= 0) && ((x+i) < MAX_X_MINES) &&
((y+j) >= 0) && ((y+j) < MAX_Y_MINES) &&
!((i == 0) && (j == 0)) )
{
if ( !(minefield[x+i][y+j].mine & MINE) &&
((minefield[x+i][y+j].mine & VISITED) != VISITED) )
{
minefield[x+i][y+j].mine |= VISITED ;
InvalidateRect (hWnd,&minefield[x+i][y+j].rect,FALSE) ;
if ( !(minefield[x+i][y+j].mine & MINES_AROUND) )
ShowAsMany (hWnd, x+i, y+j) ;
}
else
minefield[x+i][y+j].mine |= VISITED ;
}
return (FALSE) ;
}
/*...e*/
/*...sMineFloodFill\40\\41\\9\Check to see if a minefield is completable:0:*/
void MineFloodFill (HWND hWnd, int x, int y)
{
int i,j ;
if ( x < 0 || y < 0 || x >= MAX_X_MINES || y >= MAX_Y_MINES )
return ;
if ( minefield[x][y].mine & MINE+FILLED )
return ;
minefield[x][y].mine |= FILLED ;
/* InvalidateRect (hWnd, &minefield[x][y].rect, TRUE) ;
UpdateWindow (hWnd) ;
*/ for ( i = -1 ; i < 2 ; i++)
for ( j = -1 ; j < 2 ; j++ )
MineFloodFill (hWnd, x+i, y+j) ;
}
/*...e*/
/*...sCanWeDoIt\40\\41\\9\\9\Fire off Flood fill and check result:0:*/
BOOL CanWeDoIt (HWND hWnd)
{
MineFloodFill (hWnd, 0, 0) ;
if ( minefield[MAX_X_MINES-1][MAX_Y_MINES-1].mine & FILLED )
return (TRUE) ;
else
return (FALSE) ;
}
/*...e*/
/*...sMinesAboutProc\40\\41\\9\Show about window:0:*/
BOOL FAR PASCAL MinesAboutProc(HWND hWnd, unsigned message,
WORD wParam, LONG lParam )
{
if ( message == WM_COMMAND )
{
EndDialog (hWnd, TRUE) ;
return (TRUE) ;
}
else
return (FALSE) ;
}
/*...e*/
/*...sMinesNoProc\40\\41\:0:*/
BOOL FAR PASCAL MinesNoProc(HWND hWnd, unsigned message,
WORD wParam, LONG lParam )
{
WORD fred ;
switch (message)
{
/*...sWM_INITDIALOG:8:*/
case WM_INITDIALOG:
sprintf (out, "%d", NoMines) ;
SetDlgItemText (hWnd, IDD_NO_MINES, out) ;
SendMessage (GetDlgItem (hWnd, IDD_NO_MINES), EM_SETSEL, 0,MAKELONG(0,32767)) ;
SetFocus(GetDlgItem (hWnd, IDD_NO_MINES)) ;
return (FALSE) ;
/*...e*/
/*...sWM_COMMAND:8:*/
case WM_COMMAND:
switch (wParam)
{
case IDD_OK:
GetDlgItemText (hWnd, IDD_NO_MINES, out, 10) ;
fred = atoi(out) ;
if ( fred < 30 )
{
MessageBox (hWnd, "Must be at least 30 mines!", szAppName, MB_ICONEXCLAMATION | MB_OK) ;
return (TRUE) ;
}
if ( fred > 160 )
{
MessageBox (hWnd, "No more than 160 mines!", szAppName, MB_ICONEXCLAMATION | MB_OK) ;
return (TRUE) ;
}
NoMines = fred ;
EndDialog (hWnd,TRUE) ;
return (TRUE) ;
case IDD_CANCEL:
EndDialog (hWnd, FALSE) ;
return (TRUE) ;
default:
return (FALSE) ;
}
break ;
/*...e*/
/*...sdefault:8:*/
default:
return (FALSE) ;
/*...e*/
}
return (FALSE) ;
}
/*...e*/
/*...sMessage processing \45\ Main Window:0:*/
/************************************************************************/
/* T H E O V E R L A P P I N G W I N D O W P R O C E D U R E */
/************************************************************************/
/* Every message for this window is delivered right here */
long FAR PASCAL MinesWndProc (HWND hWnd,unsigned message,
WORD wParam, LONG lParam)
{
int x,y ; /* Loop for filling square */
RECT tRect ;
HDC hDC,hMemDC ;
PAINTSTRUCT ps ;
WORD MineLoop ;
static HBITMAP hMineBit,hOKBit,hVisitedBit,hAtBit,hRectBit,hWrongBit ;
static WORD XOfs, YOfs ;
TEXTMETRIC tm ;
HCURSOR hCursor ;
BOOL flag,first ;
FARPROC lpproc ;
int iOldMode ;
switch (message)
{
/*...sWM_CREATE:8:*/
/* If the annotation item is being created, then bring up a dialog box asking
for relevant information.
*/
case WM_CREATE:
srand(LOWORD (GetCurrentTime())) ;
for ( x = 0 ; x < MAX_X_MINES ; x++ )
for ( y = 0 ; y < MAX_Y_MINES ; y++ )
{
minefield[x][y].rect.top = y*16 ;
minefield[x][y].rect.bottom = y*16+16 ;
minefield[x][y].rect.left = x*16 ;
minefield[x][y].rect.right = x*16+16 ;
minefield[x][y].mine = NO_MINE ;
}
hMineBit = LoadBitmap (hInst, "AMine") ;
hOKBit = LoadBitmap (hInst, "AOK") ;
hVisitedBit = LoadBitmap (hInst, "AVisit") ;
hAtBit = LoadBitmap (hInst, "AAt") ;
hRectBit = LoadBitmap (hInst, "ARect") ;
hWrongBit = LoadBitmap (hInst, "AWrong") ;
hDC = GetDC (hWnd) ;
GetTextMetrics (hDC, &tm) ;
ReleaseDC (hWnd, hDC) ;
XOfs = (16-tm.tmAveCharWidth) / 2 ;
YOfs = (16-tm.tmHeight) / 2 ;
NoMines = GetProfileInt(szAppName,szProfile,30) ;
if ( (NoMines < 30) || (NoMines > 160) )
NoMines = 30 ;
SendMessage (hWnd, WM_SET_NO_OF_MINES, 0, 0L) ;
PostMessage (hWnd, WM_COMMAND, IDM_NEW_GAME, 0L) ;
break ;
/*...e*/
/*...sWM_DESTROY:8:*/
case WM_DESTROY:
DeleteObject (hMineBit) ;
DeleteObject (hOKBit) ;
DeleteObject (hVisitedBit) ;
DeleteObject (hAtBit) ;
DeleteObject (hRectBit) ;
DeleteObject (hWrongBit) ;
PostQuitMessage (0) ;
break ;
/*...e*/
/*...sWM_COMMAND:8:*/
case WM_COMMAND:
switch (wParam)
{
/*...sIDM_NEW_GAME:16:*/
case IDM_NEW_GAME:
PostMessage (hWnd, WM_CREATE_MINES, 0, 0L) ;
break ;
/*...e*/
/*...sIDM_QUIT:16:*/
case IDM_QUIT:
PostMessage (hWnd, WM_CLOSE, 0, 0L) ;
break ;
/*...e*/
/*...sIDM_NO_MINES:16:*/
case IDM_NO_MINES:
lpproc = MakeProcInstance ((FARPROC) MinesNoProc, hInst) ;
if ( DialogBox (hInst, "NUMBERMINES", hWnd, lpproc) )
{
SendMessage (hWnd, WM_SET_NO_OF_MINES, 0, 0L) ;
PostMessage (hWnd, WM_COMMAND, IDM_NEW_GAME, 0L) ;
}
FreeProcInstance (lpproc) ;
break ;
/*...e*/
/*...sIDM_ABOUT:16:*/
case IDM_ABOUT:
lpproc = MakeProcInstance ((FARPROC) MinesAboutProc, hInst) ;
DialogBox (hInst, "ABOUTMINES", hWnd, lpproc) ;
FreeProcInstance (lpproc) ;
break ;
/*...e*/
}
break ;
/*...e*/
/*...sWM_LBUTTONDOWN:8:*/
case WM_LBUTTONDOWN:
if ( !InGame )
{
MessageBeep(0) ;
break ;
}
x = LOWORD(lParam) / 16 ;
y = HIWORD(lParam) / 16 ;
if ( AmINearby (x,y) || (minefield[x][y].mine & VISITED) == VISITED)
{
if ( (minefield[x][y].mine & VISITED ) == THINK_MINE )
MessageBeep(0) ;
else
{
flag = minefield[x][y].mine & VISITED ;
minefield[px][py].mine &= HERE_MASK ;
minefield[x][y].mine |= HERE+VISITED ;
InvalidateRect (hWnd, &minefield[px][py].rect, FALSE) ;
InvalidateRect (hWnd, &minefield[x][y].rect, FALSE) ;
if ( flag != VISITED )
{
ShowAsMany (hWnd, x, y) ;
UpdateWindow (hWnd) ;
}
px = x ;
py = y ;
if ( minefield[x][y].mine & MINE )
{
SendMessage (hWnd, WM_HIT_MINE, 0, 0L) ;
break ;
}
if ( (minefield[MAX_X_MINES-1][MAX_Y_MINES-1].mine & VISITED) == VISITED )
SendMessage (hWnd, WM_REACHED_END, 0, 0L) ;
}
}
else
MessageBeep(0) ;
break ;
/*...e*/
/*...sWM_RBUTTONDOWN:8:*/
case WM_RBUTTONDOWN:
if ( !InGame )
{
MessageBeep(0) ;
break ;
}
x = LOWORD(lParam) / 16 ;
y = HIWORD(lParam) / 16 ;
if ( (minefield[x][y].mine & VISITED) == VISITED )
{
MessageBeep(0) ;
break ;
}
MineLoop = minefield[x][y].mine & VISITED ;
MineLoop += INC_THINK ;
if ( MineLoop > MAX_THINK )
MineLoop = 0 ;
minefield[x][y].mine = (minefield[x][y].mine & (~VISITED)) | MineLoop ;
InvalidateRect (hWnd, &minefield[x][y].rect, FALSE) ;
break ;
/*...e*/
/*...sWM_PAINT:8:*/
case WM_PAINT:
hDC = BeginPaint (hWnd, &ps) ;
iOldMode = GetBkMode(hDC) ;
SetBkMode(hDC,TRANSPARENT) ;
for ( x = 0 ; x < MAX_X_MINES ; x++ )
for (y = 0 ; y < MAX_Y_MINES ; y++ )
{
/* tRect = minefield[x][y].rect ; */
if ( IntersectRect (&tRect, &minefield[x][y].rect,&ps.rcPaint) )
switch (minefield[x][y].mine & PAINT_MASK)
{
/*...sVISITED:32:*/
case VISITED:
/* Display no of mines around */
hMemDC = CreateCompatibleDC (hDC) ;
if ( (minefield[x][y].mine & HERE) )
SelectObject (hMemDC, hAtBit) ;
else
SelectObject (hMemDC, hVisitedBit) ;
BitBlt (hDC, x*16, y*16, 16, 16, hMemDC, 0, 0, SRCCOPY) ;
if ( minefield[x][y].mine & MINES_AROUND )
{
sprintf (out,"%d",minefield[x][y].mine & MINES_AROUND) ;
TextOut (hDC, x*16+XOfs, y*16+YOfs, out, strlen(out)) ;
}
DeleteDC (hMemDC) ;
break ;
/*...e*/
/*...sTHINK_OK:32:*/
case THINK_OK:
hMemDC = CreateCompatibleDC (hDC) ;
SelectObject (hMemDC, hOKBit) ;
BitBlt (hDC, x*16, y*16, 16, 16, hMemDC, 0, 0, SRCCOPY) ;
DeleteDC (hMemDC) ;
break ;
/*...e*/
/*...sTHINK_MINE:32:*/
case THINK_MINE:
hMemDC = CreateCompatibleDC (hDC) ;
SelectObject (hMemDC, hMineBit) ;
BitBlt (hDC, x*16, y*16, 16, 16, hMemDC, 0, 0, SRCCOPY) ;
DeleteDC (hMemDC) ;
break ;
/*...e*/
/*...sNOT_SURE:32:*/
case NOT_SURE:
hMemDC = CreateCompatibleDC (hDC) ;
SelectObject (hMemDC, hRectBit) ;
BitBlt (hDC, x*16, y*16, 16, 16, hMemDC, 0, 0, SRCCOPY) ;
DeleteDC (hMemDC) ;
break ;
/*...e*/
/*...sINV_OK:32:*/
case INV_OK:
hMemDC = CreateCompatibleDC (hDC) ;
SelectObject (hMemDC, hWrongBit) ;
BitBlt (hDC, x*16, y*16, 16, 16, hMemDC, 0, 0, SRCCOPY) ;
DeleteDC (hMemDC) ;
break ;
/*...e*/
/*...sINV_MINE:32:*/
case INV_MINE:
hMemDC = CreateCompatibleDC (hDC) ;
SelectObject (hMemDC, hWrongBit) ;
BitBlt (hDC, x*16, y*16, 16, 16, hMemDC, 0, 0, SRCCOPY) ;
DeleteDC (hMemDC) ;
break ;
/*...e*/
}
}
SetBkMode(hDC,iOldMode) ;
EndPaint (hWnd, &ps) ;
break ;
/*...e*/
/*...sWM_CREATE_MINES:8:*/
case WM_CREATE_MINES:
SetCapture (hWnd) ;
hCursor = SetCursor (LoadCursor (NULL, IDC_WAIT)) ;
first = TRUE ;
do
{
for ( x = 0 ; x < MAX_X_MINES ; x++ )
for ( y = 0 ; y < MAX_Y_MINES ; y++ )
minefield[x][y].mine = NO_MINE ;
if ( !first )
MessageBeep(0) ;
first = FALSE ;
MineLoop = NoMines ;
while ( MineLoop )
{
x = rand() & 15 ;
y = rand() & 15 ;
if ( (minefield[x][y].mine == NO_MINE) && !((x <= 1) && (y <= 1)) )
{
minefield[x][y].mine = MINE ;
MineLoop-- ;
}
}
minefield[MAX_X_MINES-1][MAX_Y_MINES-1].mine = NO_MINE ;
/* InvalidateRect (hWnd, NULL, FALSE) ;
SendMessage (hWnd, WM_SHOW_MINES, 0, 0L) ;
*/ }
while ( !CanWeDoIt(hWnd) ) ;
for ( x = 0 ; x < MAX_X_MINES ; x++ )
for ( y = 0 ; y < MAX_Y_MINES ; y++ )
minefield[x][y].mine |= CountMines(x,y) ;
minefield[0][0].mine = HERE+VISITED ;
InvalidateRect (hWnd, NULL, FALSE) ;
ShowAsMany (hWnd, 0, 0) ;
UpdateWindow (hWnd) ;
SetCursor (hCursor) ;
ReleaseCapture() ;
px = py = 0 ;
InGame = TRUE ;
break ;
/*...e*/
/*...sWM_HIT_MINE:8:*/
case WM_HIT_MINE:
hDC = GetDC (hWnd) ;
GetClientRect (hWnd, &tRect) ;
MessageBeep(0) ;
InvertRect (hDC, &tRect) ;
MessageBeep(0) ;
InvertRect (hDC, &tRect) ;
MessageBeep(0) ;
ReleaseDC (hWnd, hDC) ;
SendMessage (hWnd, WM_SHOW_MINES, 0, 0L) ;
InGame = FALSE ;
break ;
/*...e*/
/*...sWM_REACHED_END:8:*/
case WM_REACHED_END:
SendMessage (hWnd, WM_SHOW_MINES, 0, 0L) ;
MessageBox (hWnd, "You made it!", "Congratualtions", MB_OK) ;
InGame = FALSE ;
break ;
/*...e*/
/*...sWM_SHOW_MINES:8:*/
case WM_SHOW_MINES:
minefield[px][py].mine &= HERE_MASK ;
for (x = 0 ; x < MAX_X_MINES ; x++ )
for (y = 0 ; y < MAX_Y_MINES ; y++ )
if ( (minefield[x][y].mine & MINE) &&
(minefield[x][y].mine & VISITED) == THINK_OK )
{
minefield[x][y].mine &= (~PAINT_MASK) ;
minefield[x][y].mine |= INV_MINE ;
InvalidateRect (hWnd, &minefield[x][y].rect, FALSE) ;
}
else
if ( !(minefield[x][y].mine & MINE) &&
(minefield[x][y].mine & VISITED) == THINK_MINE )
{
minefield[x][y].mine &= (~PAINT_MASK) ;
minefield[x][y].mine |= INV_OK ;
InvalidateRect (hWnd, &minefield[x][y].rect, FALSE) ;
}
else
if ( minefield[x][y].mine & MINE )
{
minefield[x][y].mine &= (~VISITED) ;
minefield[x][y].mine |= THINK_MINE ;
InvalidateRect (hWnd, &minefield[x][y].rect, FALSE) ;
}
UpdateWindow (hWnd) ;
break ;
/*...e*/
/*...sWM_SET_NO_OF_MINES:8:*/
case WM_SET_NO_OF_MINES:
sprintf (out,"%d",NoMines) ;
WriteProfileString(szAppName,szProfile,out) ;
sprintf (out, "Playing with %d mines!", NoMines) ;
SetWindowText (hWnd, out) ;
break ;
/*...e*/
/*...sdefault:8:*/
default:
return (DefWindowProc (hWnd, message, wParam, lParam)) ;
/*...e*/
}
return (0L) ;
}
/*...e*/
/*...sInitialisation:0:*/
/************************************************************************/
/* I N I T I A L I S A T I O N */
/************************************************************************/
/*...sInitialise for first instance:0:*/
/************************************************************************/
/* F I R S T - I N S T A N C E I N I T I A L I S A T I O N */
/************************************************************************/
/*
Done first time only. Normally register the window class.
*/
void InitMinesFirst (HANDLE hInstance)
{
WNDCLASS wcMinesClass ;
wcMinesClass.lpszClassName = szAppName ;
wcMinesClass.hInstance = hInstance ;
wcMinesClass.lpfnWndProc = MinesWndProc ;
wcMinesClass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wcMinesClass.hIcon = LoadIcon (hInstance, "MINESICON") ;
wcMinesClass.lpszMenuName = "MinesMenu" ;
wcMinesClass.hbrBackground = GetStockObject (WHITE_BRUSH) ;
wcMinesClass.style = CS_HREDRAW | CS_VREDRAW ;
wcMinesClass.cbClsExtra = 0 ;
wcMinesClass.cbWndExtra = 0 ;
RegisterClass (&wcMinesClass) ;
}
/*...e*/
/*...sInitialise for 2nd or greater instance:0:*/
/************************************************************************/
/* A D D E D - I N S T A N C E I N I T I A L I S A T I O N */
/************************************************************************/
/*
Done for every instance other than the first. Normally copy the
results of the previous instance's initialisation.
*/
void InitMinesAdded (HANDLE hInstance,HANDLE hPrevInstance)
{
GetInstanceData (hPrevInstance, (PSTR)&SetUpData, sizeof(SETUPDATA)) ;
}
/*...e*/
/*...sInitialise for every instance:0:*/
/************************************************************************/
/* E V E R Y - I N S T A N C E I N I T I A L I S A T I O N */
/************************************************************************/
/*
Done for each instance of the application.
Normally :-
Create the window (Cause an instance of the window to exist)
Show the window (Cause the window to be drawn on the screen)
Update the window (Cause the paint proc to be executed (now))
*/
void InitMinesEvery (HANDLE hInstance, int cmdShow)
{
hInst = hInstance ;
hWnd = CreateWindow(szAppName, /* Window Class Name */
NULL,
WS_OVERLAPPED | WS_DLGFRAME |
WS_CAPTION | WS_SYSMENU |
WS_MINIMIZEBOX, /* Window Style */
/* Type of window */
CW_USEDEFAULT, /* x - Default location */
CW_USEDEFAULT, /* y */
16*MAX_X_MINES+1,
16*MAX_Y_MINES+1+GetSystemMetrics(SM_CYCAPTION)+
GetSystemMetrics(SM_CYMENU),
/* cy - Half Size*/
NULL, /* No parent for this w.*/
NULL, /* Use the class menu */
hInstance, /* Who created this w. */
NULL /* No params to pass on */
) ;
ShowWindow (hWnd,cmdShow) ;
UpdateWindow (hWnd) ;
}
/*...e*/
void InitMines (HANDLE hInstance,HANDLE hPrevInstance,int cmdShow)
{
if (!hPrevInstance)
InitMinesFirst (hInstance) ;
else
InitMinesAdded (hInstance, hPrevInstance) ;
InitMinesEvery (hInstance, cmdShow) ;
}
/*...e*/
/*...sClosing Routine:0:*/
/************************************************************************/
/* C L O S I N G R O U T I N E */
/************************************************************************/
void CloseMines (HANDLE hInstance)
{
/* Perform any special processing before shutting down the window */
}
/*...e*/
/*...sMain Procedure:0:*/
/************************************************************************/
/* M A I N P R O C E D U R E */
/************************************************************************/
int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance,
LPSTR lpszCmdLine,int cmdShow)
{
MSG msg ; /* Temp buffer to hold message */
InitMines (hInstance, hPrevInstance, cmdShow) ; /* Initialise*/
hAccel = LoadAccelerators (hInst, "MinesAccel") ;
while (GetMessage(&msg, NULL, 0, 0))
if ( !TranslateAccelerator (hWnd, hAccel, &msg) )
{
TranslateMessage(&msg) ;
DispatchMessage(&msg) ;
}
CloseMines (hInstance) ;
return (msg.wParam) ;
}
/*...e*/