ReactOS  0.4.14-dev-604-gcfdd483
spider.cpp File Reference
#include "spider.h"
#include <commctrl.h>
#include <tchar.h>
Include dependency graph for spider.cpp:

Go to the source code of this file.

Classes

struct  _CardBack
 

Typedefs

typedef struct _CardBack CARDBACK
 
typedef struct _CardBackPCARDBACK
 

Functions

LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
 
void MakePath (TCHAR *szDest, UINT nDestLen, const TCHAR *szExt)
 
INT_PTR CALLBACK DifficultyDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
int WINAPI _tWinMain (HINSTANCE hInst, HINSTANCE hPrev, LPTSTR szCmdLine, int iCmdShow)
 
LRESULT CALLBACK CardImageWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
INT_PTR CALLBACK CardBackDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
VOID ShowDeckOptionsDlg (HWND hwnd)
 

Variables

TCHAR szHelpPath [MAX_PATH]
 
DWORD dwAppStartTime
 
HWND hwndMain
 
HINSTANCE hInstance
 
TCHAR szAppName [128]
 
TCHAR MsgQuit [128]
 
TCHAR MsgAbout [128]
 
TCHAR MsgWin [128]
 
TCHAR MsgDeal [128]
 
DWORD dwDifficulty
 
CardWindow SpiderWnd
 

Typedef Documentation

◆ CARDBACK

◆ PCARDBACK

Function Documentation

◆ _tWinMain()

int WINAPI _tWinMain ( HINSTANCE  hInst,
HINSTANCE  hPrev,
LPTSTR  szCmdLine,
int  iCmdShow 
)

Definition at line 81 of file spider.cpp.

82 {
83  HWND hwnd;
84  MSG msg;
85  WNDCLASS wndclass;
87  HACCEL hAccelTable;
88 
89  hInstance = hInst;
90 
91  /* Load application title */
92  LoadString(hInst, IDS_SPI_NAME, szAppName, sizeof(szAppName) / sizeof(szAppName[0]));
93  /* Load MsgBox() texts here to avoid loading them many times later */
94  LoadString(hInst, IDS_SPI_ABOUT, MsgAbout, sizeof(MsgAbout) / sizeof(MsgAbout[0]));
95  LoadString(hInst, IDS_SPI_QUIT, MsgQuit, sizeof(MsgQuit) / sizeof(MsgQuit[0]));
96  LoadString(hInst, IDS_SPI_WIN, MsgWin, sizeof(MsgWin) / sizeof(MsgWin[0]));
97  LoadString(hInst, IDS_SPI_DEAL, MsgDeal, sizeof(MsgDeal) / sizeof(MsgDeal[0]));
98 
99  /* Window class for the main application parent window */
100  wndclass.style = 0;
101  wndclass.lpfnWndProc = WndProc;
102  wndclass.cbClsExtra = 0;
103  wndclass.cbWndExtra = 0;
104  wndclass.hInstance = hInst;
106  wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
107  wndclass.hbrBackground = (HBRUSH)NULL;
109  wndclass.lpszClassName = szAppName;
110 
111  RegisterClass(&wndclass);
112 
113  ice.dwSize = sizeof(ice);
114  ice.dwICC = ICC_BAR_CLASSES;
115  InitCommonControlsEx(&ice);
116 
117  srand((unsigned)GetTickCount());
118 
119  /* InitCardLib(); */
120 
121  /* Construct the path to our help file */
122  MakePath(szHelpPath, MAX_PATH, _T(".hlp"));
123 
125  szAppName,
129  0, /*The real size will be computed in WndProc through WM_GETMINMAXINFO */
130  0, /* The real size will be computed in WndProc through WM_GETMINMAXINFO */
131  NULL,
132  NULL,
133  hInst,
134  NULL);
135 
136  hwndMain = hwnd;
137 
138  ShowWindow(hwnd, iCmdShow);
140 
142 
144 
145  while (GetMessage(&msg, NULL,0,0))
146  {
147  if (!TranslateAccelerator(hwnd, hAccelTable, &msg))
148  {
151  }
152  }
153  return msg.wParam;
154 }
#define IDS_SPI_ABOUT
Definition: resource.h:38
void MakePath(TCHAR *szDest, UINT nDestLen, const TCHAR *szExt)
Definition: spider.cpp:40
#define TranslateAccelerator
Definition: winuser.h:5835
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define DispatchMessage
Definition: winuser.h:5740
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define IDR_ACCELERATOR1
Definition: resource.h:7
#define CreateWindow
Definition: winuser.h:5729
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define IDR_MENU1
Definition: resource.h:6
BOOL WINAPI UpdateWindow(_In_ HWND)
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
void __cdecl srand(_In_ unsigned int _Seed)
HINSTANCE hInstance
Definition: spider.cpp:18
int cbClsExtra
Definition: winuser.h:3140
LPCSTR lpszMenuName
Definition: winuser.h:3146
HBRUSH hbrBackground
Definition: winuser.h:3145
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
HWND hwndMain
Definition: spider.cpp:17
#define IDD_DIFFICULTY
Definition: resource.h:31
#define DialogBox
Definition: winuser.h:5736
int cbWndExtra
Definition: winuser.h:3141
#define LoadAccelerators
Definition: winuser.h:5785
HCURSOR hCursor
Definition: winuser.h:3144
#define CW_USEDEFAULT
Definition: winuser.h:225
#define IDS_SPI_DEAL
Definition: resource.h:41
smooth NULL
Definition: ftsmooth.c:416
TCHAR MsgDeal[128]
Definition: spider.cpp:24
#define IDS_SPI_QUIT
Definition: resource.h:39
#define ICC_BAR_CLASSES
Definition: commctrl.h:60
#define _T(x)
Definition: vfdio.h:22
#define MAX_PATH
Definition: compat.h:26
TCHAR szHelpPath[MAX_PATH]
Definition: spider.cpp:14
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
#define IDI_SPIDER
Definition: resource.h:4
LPCSTR lpszClassName
Definition: winuser.h:3147
#define LoadCursor
Definition: winuser.h:5787
UINT style
Definition: winuser.h:3138
TCHAR MsgAbout[128]
Definition: spider.cpp:22
HINSTANCE hInst
Definition: dxdiag.c:13
HINSTANCE hInstance
Definition: winuser.h:3142
INT_PTR CALLBACK DifficultyDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: spider.cpp:49
#define GetMessage
Definition: winuser.h:5765
WNDPROC lpfnWndProc
Definition: winuser.h:3139
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
TCHAR MsgQuit[128]
Definition: spider.cpp:21
#define IDS_SPI_WIN
Definition: resource.h:40
#define RegisterClass
Definition: winuser.h:5811
#define LoadIcon
Definition: winuser.h:5788
TCHAR MsgWin[128]
Definition: spider.cpp:23
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
Definition: spider.cpp:305
TCHAR szAppName[128]
Definition: spider.cpp:20
#define IDS_SPI_NAME
Definition: resource.h:37
#define LoadString
Definition: winuser.h:5794
HICON hIcon
Definition: winuser.h:3143

◆ CardBackDlgProc()

INT_PTR CALLBACK CardBackDlgProc ( HWND  hDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 225 of file spider.cpp.

226 {
227  static PCARDBACK pCardBacks = NULL;
228 
229  switch (uMsg)
230  {
231  case WM_INITDIALOG:
232  {
233  INT i, c;
234  SIZE_T size = sizeof(CARDBACK) * NUM_CARDBACKS;
235 
236  pCardBacks = (PCARDBACK)HeapAlloc(GetProcessHeap(), 0, size);
237 
238  if (!pCardBacks)
239  return FALSE;
240 
241  for (i = 0, c = CARDBACK_START; c <= CARDBACK_END; i++, c++)
242  {
243  pCardBacks[i].hSelf = GetDlgItem(hDlg, c);
244  pCardBacks[i].bSelected = FALSE;
245  pCardBacks[i].hdcNum = CARDBACK_RES_START + i;
246  pCardBacks[i].imgNum = i + 1;
247  pCardBacks[i].hOldProc = (WNDPROC)SetWindowLongPtr(pCardBacks[i].hSelf,
248  GWLP_WNDPROC,
250 
251  SetWindowLongPtr(pCardBacks[i].hSelf, GWLP_USERDATA, (LONG_PTR)&pCardBacks[i]);
252  }
253 
254  return TRUE;
255  }
256 
257  case WM_COMMAND:
258  if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
259  {
260  INT i, num = 0;
261  for (i = 0; i < NUM_CARDBACKS; i++)
262  {
263  if (pCardBacks[i].bSelected)
264  {
265  num = pCardBacks[i].imgNum;
266  }
267  }
268 
269  EndDialog(hDlg, LOWORD(wParam) == IDOK ? num : FALSE);
270  HeapFree(GetProcessHeap(), 0, pCardBacks);
271  return TRUE;
272  }
273 
274  if (HIWORD(wParam) == STN_CLICKED)
275  {
276  INT i;
277  RECT rc;
278  for (i = 0; i < NUM_CARDBACKS; i++)
279  {
280  pCardBacks[i].bSelected = pCardBacks[i].hSelf == (HWND)lParam;
281 
282  GetClientRect(pCardBacks[i].hSelf, &rc);
283  InvalidateRect(pCardBacks[i].hSelf, &rc, TRUE);
284  }
285 
286  break;
287  }
288  }
289 
290  return FALSE;
291 }
HWND hSelf
Definition: solitaire.cpp:36
INT imgNum
Definition: solitaire.cpp:39
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
struct _CardBack * PCARDBACK
HANDLE HWND
Definition: compat.h:13
#define CARDBACK_RES_START
Definition: solitaire.h:19
int32_t INT
Definition: typedefs.h:56
#define SetWindowLongPtr
Definition: treelist.c:70
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LRESULT CALLBACK CardImageWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: spider.cpp:156
#define GWLP_USERDATA
Definition: treelist.c:63
smooth NULL
Definition: ftsmooth.c:416
WNDPROC hOldProc
Definition: solitaire.cpp:37
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define STN_CLICKED
Definition: winuser.h:2076
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
const GLubyte * c
Definition: glext.h:8905
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define CARDBACK_START
Definition: solitaire.h:16
GLuint GLuint num
Definition: glext.h:9618
BOOL bSelected
Definition: solitaire.cpp:40
#define NUM_CARDBACKS
Definition: solitaire.h:18
#define WM_COMMAND
Definition: winuser.h:1722
#define GWLP_WNDPROC
Definition: treelist.c:66
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2881
struct _CardBack CARDBACK
ULONG_PTR SIZE_T
Definition: typedefs.h:78
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define CARDBACK_END
Definition: solitaire.h:17
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define c
Definition: ke_i.h:80
#define HIWORD(l)
Definition: typedefs.h:246
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:402
INT hdcNum
Definition: solitaire.cpp:38

Referenced by ShowDeckOptionsDlg().

◆ CardImageWndProc()

LRESULT CALLBACK CardImageWndProc ( HWND  hwnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 156 of file spider.cpp.

157 {
159  static WNDPROC hOldProc = NULL;
160 
161  if (!pCardBack)
162  return FALSE;
163 
164  if (!hOldProc)
165  hOldProc = pCardBack->hOldProc;
166 
167  switch (msg)
168  {
169  case WM_PAINT:
170  {
171  HDC hdc;
172  PAINTSTRUCT ps;
173  HPEN hPen, hOldPen;
174  HBRUSH hBrush, hOldBrush;
175  RECT rc;
176 
177  hdc = BeginPaint(hwnd, &ps);
178 
179  if (pCardBack->bSelected)
180  {
181  hPen = CreatePen(PS_SOLID, 2, RGB(0,0,0));
182  }
183  else
184  {
186  hPen = CreatePen(PS_SOLID, 2, Face);
187  }
188 
189  GetClientRect(hwnd, &rc);
190  hBrush = (HBRUSH)GetStockObject(NULL_BRUSH);
191  hOldPen = (HPEN)SelectObject(hdc, hPen);
192  hOldBrush = (HBRUSH)SelectObject(hdc, hBrush);
193 
194  Rectangle(hdc, rc.left+1, rc.top+1, rc.right, rc.bottom);
195 
196  StretchBlt(hdc,
197  2,
198  2,
202  pCardBack->hdcNum * __cardwidth,
203  0,
204  __cardwidth,
205  __cardheight,
206  SRCCOPY);
207 
208  SelectObject(hdc, hOldPen);
209  SelectObject(hdc, hOldBrush);
210 
211  EndPaint(hwnd, &ps);
212 
213  break;
214  }
215 
216  case WM_LBUTTONDOWN:
217  pCardBack->bSelected = pCardBack->bSelected ? FALSE : TRUE;
218  break;
219  }
220 
221  return CallWindowProc(hOldProc, hwnd, msg, wParam, lParam);
222 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define CallWindowProc
Definition: winuser.h:5710
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
struct _CardBack * PCARDBACK
#define NULL_BRUSH
Definition: wingdi.h:900
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
LONG left
Definition: windef.h:306
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
LONG right
Definition: windef.h:308
DWORD WINAPI GetSysColor(_In_ int)
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
WPARAM wParam
Definition: combotst.c:138
HDC __hdcCardBitmaps
Definition: cardlib.cpp:18
#define PS_SOLID
Definition: wingdi.h:585
#define CARDBACK_OPTIONS_HEIGHT
Definition: solitaire.h:21
#define COLOR_3DFACE
Definition: winuser.h:919
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define GWLP_USERDATA
Definition: treelist.c:63
smooth NULL
Definition: ftsmooth.c:416
WNDPROC hOldProc
Definition: solitaire.cpp:37
#define RGB(r, g, b)
Definition: wingdi.h:2939
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL bSelected
Definition: solitaire.cpp:40
#define WM_PAINT
Definition: winuser.h:1602
HDC hdc
Definition: main.c:9
int __cardwidth
Definition: cardlib.cpp:25
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2881
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define msg(x)
Definition: auth_time.c:54
int __cardheight
Definition: cardlib.cpp:26
LONG bottom
Definition: windef.h:309
#define GetWindowLongPtr
Definition: treelist.c:73
#define CARDBACK_OPTIONS_WIDTH
Definition: solitaire.h:20
LPARAM lParam
Definition: combotst.c:139
#define SRCCOPY
Definition: wingdi.h:332
INT hdcNum
Definition: solitaire.cpp:38

Referenced by CardBackDlgProc().

◆ DifficultyDlgProc()

INT_PTR CALLBACK DifficultyDlgProc ( HWND  hDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 49 of file spider.cpp.

50 {
51  switch (uMsg)
52  {
53  case WM_INITDIALOG:
55  return TRUE;
56 
57  case WM_COMMAND:
58  switch(LOWORD(wParam))
59  {
60  case IDOK:
67 
68  NewGame();
69  EndDialog(hDlg, TRUE);
70  return TRUE;
71 
72  case IDCANCEL:
73  EndDialog(hDlg, FALSE);
74  return TRUE;
75  }
76  break;
77  }
78  return FALSE;
79 }
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
void NewGame(void)
Definition: solgame.cpp:17
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
#define WM_COMMAND
Definition: winuser.h:1722
DWORD dwDifficulty
Definition: spider.cpp:25
#define IDC_DIF_ONECOLOR
Definition: resource.h:32
#define IDC_DIF_TWOCOLORS
Definition: resource.h:33
#define BST_CHECKED
Definition: winuser.h:197
#define IDC_DIF_FOURCOLORS
Definition: resource.h:34
BOOL WINAPI CheckRadioButton(_In_ HWND, _In_ int, _In_ int, _In_ int)
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1721
#define LOWORD(l)
Definition: pedump.c:82

Referenced by _tWinMain().

◆ MakePath()

void MakePath ( TCHAR szDest,
UINT  nDestLen,
const TCHAR szExt 
)

Definition at line 40 of file spider.cpp.

41 {
42  TCHAR *ptr;
43 
44  ptr = szDest + GetModuleFileName(GetModuleHandle(0), szDest, nDestLen) - 1;
45  while(*ptr-- != '.');
46  lstrcpy(ptr + 1, szExt);
47 }
static PVOID ptr
Definition: dispmode.c:27
char TCHAR
Definition: xmlstorage.h:189
#define GetModuleFileName
Definition: winbase.h:3665
#define GetModuleHandle
Definition: winbase.h:3661
#define lstrcpy
Definition: winbase.h:3708

Referenced by _tWinMain().

◆ ShowDeckOptionsDlg()

VOID ShowDeckOptionsDlg ( HWND  hwnd)

Definition at line 294 of file spider.cpp.

295 {
296  INT cardBack;
297 
299  {
300  SpiderWnd.SetBackCardIdx(CARDBACK_RES_START + (cardBack - 1));
301  SpiderWnd.Redraw();
302  }
303 }
#define IDD_CARDBACK
Definition: resource.h:27
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MAKEINTRESOURCE
Definition: winuser.h:591
CardWindow SpiderWnd
Definition: spider.cpp:27
HINSTANCE hInstance
Definition: spider.cpp:18
#define CARDBACK_RES_START
Definition: solitaire.h:19
int32_t INT
Definition: typedefs.h:56
void Redraw(void)
Definition: cardwindow.cpp:553
#define DialogBox
Definition: winuser.h:5736
INT_PTR CALLBACK CardBackDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: spider.cpp:225
void SetBackCardIdx(UINT uBackIdx)
Definition: cardwindow.cpp:728

Referenced by WndProc().

◆ WndProc()

LRESULT CALLBACK WndProc ( HWND  hwnd,
UINT  iMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 305 of file spider.cpp.

306 {
307  static int nWidth, nHeight;
308 
309  switch (iMsg)
310  {
311  case WM_CREATE:
312  {
313  // For now, the Help dialog is disabled because of lacking of HTML Help support
315 
316  SpiderWnd.Create(hwnd, 0, WS_CHILD | WS_VISIBLE, 0, 0, 100, 100);
318  CreateSpider();
319 
320  SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOZORDER);
321 
323 
324  return 0;
325  }
326 
327  case WM_DESTROY:
328  PostQuitMessage(0);
329  return 0;
330 
331  case WM_SIZE:
332  nWidth = LOWORD(lParam);
333  nHeight = HIWORD(lParam);
334 
335  MoveWindow(SpiderWnd, 0, 0, nWidth, nHeight, TRUE);
336  return 0;
337 
338  case WM_GETMINMAXINFO:
339  {
340  MINMAXINFO *mmi;
341 
342  mmi = (MINMAXINFO *)lParam;
343  mmi->ptMinTrackSize.x = NUM_STACKS * __cardwidth + (NUM_STACKS + 3) * X_BORDER + 12; // Border left and right of 6px
346  2 * Y_BORDER +
347  3 * __cardheight +
349  return 0;
350  }
351 
352  case WM_COMMAND:
353  switch (LOWORD(wParam))
354  {
355  case IDM_GAME_NEW:
356  NewGame();
357  return 0;
358 
359  case IDM_GAME_DECK:
361  return 0;
362 
363  case IDM_HELP_CONTENTS:
364  WinHelp(hwnd, szHelpPath, HELP_CONTENTS, 0);//HELP_KEY, (DWORD)"How to play");
365  return 0;
366 
367  case IDM_HELP_ABOUT:
369  return 0;
370 
371  case IDM_GAME_EXIT:
372  PostMessage(hwnd, WM_CLOSE, 0, 0);
373  return 0;
374  }
375 
376  return 0;
377 
378  case WM_CLOSE:
379  if (fGameStarted == false)
380  {
382  return 0;
383  }
384  else
385  {
386  int ret;
387 
389  if (ret == IDYES)
390  {
393  }
394  }
395  return 0;
396  }
397  return DefWindowProc (hwnd, iMsg, wParam, lParam);
398 }
POINT ptMinTrackSize
Definition: winuser.h:3605
#define Y_BORDER
Definition: solitaire.h:53
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
#define HELP_CONTENTS
Definition: winuser.h:2380
CardWindow SpiderWnd
Definition: spider.cpp:27
#define MF_BYCOMMAND
Definition: winuser.h:202
long y
Definition: polytest.cpp:48
#define IDYES
Definition: winuser.h:829
long x
Definition: polytest.cpp:48
#define X_BORDER
Definition: solitaire.h:49
BOOL Create(HWND hwndParent, DWORD dwExStyle, DWORD dwStyle, int x, int y, int width, int height)
Definition: cardwindow.cpp:109
#define HELP_QUIT
Definition: winuser.h:2389
DWORD dwAppStartTime
Definition: spider.cpp:16
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
#define IDM_GAME_DECK
Definition: resource.h:11
int yRowStackCardOffset
Definition: solcreate.cpp:12
#define IDM_HELP_ABOUT
Definition: resource.h:385
#define WS_CHILD
Definition: pedump.c:617
#define SWP_NOZORDER
Definition: winuser.h:1232
void CreateSpider(void)
Definition: spigame.cpp:279
BOOL WINAPI DestroyWindow(_In_ HWND)
WPARAM wParam
Definition: combotst.c:138
void NewGame(void)
Definition: solgame.cpp:17
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MB_YESNO
Definition: winuser.h:811
smooth NULL
Definition: ftsmooth.c:416
#define MB_ICONQUESTION
Definition: winuser.h:783
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
#define PostMessage
Definition: winuser.h:5807
#define IDM_HELP_CONTENTS
Definition: resource.h:14
#define SM_CYCAPTION
Definition: winuser.h:953
#define WM_SIZE
Definition: winuser.h:1593
#define WM_CLOSE
Definition: winuser.h:1603
int WINAPI GetSystemMetrics(_In_ int)
TCHAR szHelpPath[MAX_PATH]
Definition: spider.cpp:14
#define MB_ICONINFORMATION
Definition: winuser.h:796
int ret
#define MessageBox
Definition: winuser.h:5797
#define WM_COMMAND
Definition: winuser.h:1722
DWORD dwDifficulty
Definition: spider.cpp:25
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
int __cardwidth
Definition: cardlib.cpp:25
#define IDC_DIF_ONECOLOR
Definition: resource.h:32
TCHAR MsgAbout[128]
Definition: spider.cpp:22
#define IDM_GAME_EXIT
Definition: resource.h:13
#define IDM_GAME_NEW
Definition: resource.h:10
bool fGameStarted
Definition: solgame.cpp:14
#define MB_OK
Definition: winuser.h:784
VOID ShowDeckOptionsDlg(HWND hwnd)
Definition: spider.cpp:294
int __cardheight
Definition: cardlib.cpp:26
#define WM_CREATE
Definition: winuser.h:1590
TCHAR MsgQuit[128]
Definition: spider.cpp:21
#define HIWORD(l)
Definition: typedefs.h:246
#define SWP_NOMOVE
Definition: winuser.h:1229
#define NUM_STACKS
Definition: spider.h:21
#define SM_CYMENU
Definition: winuser.h:966
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define MF_GRAYED
Definition: winuser.h:129
#define WS_VISIBLE
Definition: pedump.c:620
HMENU WINAPI GetMenu(_In_ HWND)
TCHAR szAppName[128]
Definition: spider.cpp:20
LPARAM lParam
Definition: combotst.c:139
#define WM_GETMINMAXINFO
Definition: winuser.h:1622
#define LOWORD(l)
Definition: pedump.c:82
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WinHelp
Definition: winuser.h:5839

Referenced by _tWinMain().

Variable Documentation

◆ dwAppStartTime

DWORD dwAppStartTime

Definition at line 16 of file spider.cpp.

Referenced by WndProc().

◆ dwDifficulty

DWORD dwDifficulty

Definition at line 25 of file spider.cpp.

Referenced by CreatePlayDeck(), DifficultyDlgProc(), and WndProc().

◆ hInstance

HINSTANCE hInstance

Definition at line 18 of file spider.cpp.

Referenced by _tWinMain(), and ShowDeckOptionsDlg().

◆ hwndMain

HWND hwndMain

Definition at line 17 of file spider.cpp.

Referenced by _tWinMain().

◆ MsgAbout

TCHAR MsgAbout[128]

Definition at line 22 of file spider.cpp.

Referenced by _tWinMain(), and WndProc().

◆ MsgDeal

TCHAR MsgDeal[128]

Definition at line 24 of file spider.cpp.

Referenced by _tWinMain(), GameFinished(), and SuitStackAddProc().

◆ MsgQuit

TCHAR MsgQuit[128]

Definition at line 21 of file spider.cpp.

Referenced by _tWinMain(), and WndProc().

◆ MsgWin

TCHAR MsgWin[128]

Definition at line 23 of file spider.cpp.

Referenced by _tWinMain(), GameFinished(), and SuitStackAddProc().

◆ SpiderWnd

CardWindow SpiderWnd

◆ szAppName

TCHAR szAppName[128]

Definition at line 20 of file spider.cpp.

Referenced by _tWinMain(), and WndProc().

◆ szHelpPath

TCHAR szHelpPath[MAX_PATH]

Definition at line 14 of file spider.cpp.

Referenced by _tWinMain(), and WndProc().