ReactOS 0.4.15-dev-8138-g1e75ea8
solitaire.cpp File Reference
#include "solitaire.h"
#include <winreg.h>
#include <commctrl.h>
#include <shellapi.h>
#include <tchar.h>
#include "resource.h"
Include dependency graph for solitaire.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)
 
VOID LoadSettings (VOID)
 
VOID SaveSettings (VOID)
 
int GetScoreMode (void)
 
void UpdateStatusBar (void)
 
void SetPlayTimer (void)
 
void SetUndoMenuState (bool enable)
 
int WINAPI _tWinMain (HINSTANCE hInst, HINSTANCE hPrev, LPTSTR szCmdLine, int iCmdShow)
 
INT_PTR CALLBACK OptionsDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
VOID ShowGameOptionsDlg (HWND hwnd)
 
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
 
HWND hwndStatus
 
HINSTANCE hInstance
 
HMENU hGameMenu
 
TCHAR szAppName [128]
 
TCHAR szScore [64]
 
TCHAR szTime [64]
 
TCHAR MsgQuit [128]
 
TCHAR MsgAbout [128]
 
TCHAR MsgWin [128]
 
TCHAR MsgDeal [128]
 
DWORD dwOptions = OPTION_THREE_CARDS
 
DWORD dwTime
 
DWORD dwWasteCount
 
DWORD dwWasteTreshold
 
DWORD dwPrevMode
 
long lScore
 
UINT_PTR PlayTimer = 0
 
CardWindow SolWnd
 

Typedef Documentation

◆ CARDBACK

◆ PCARDBACK

Function Documentation

◆ _tWinMain()

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

Definition at line 198 of file solitaire.cpp.

199{
200 HWND hwnd;
201 MSG msg;
202 WNDCLASS wndclass;
204 HACCEL hAccelTable;
205
207
208 // Load application title
209 LoadString(hInst, IDS_SOL_NAME, szAppName, sizeof(szAppName) / sizeof(szAppName[0]));
210 // Load MsgBox() texts here to avoid loading them many times later
211 LoadString(hInst, IDS_SOL_ABOUT, MsgAbout, sizeof(MsgAbout) / sizeof(MsgAbout[0]));
212 LoadString(hInst, IDS_SOL_QUIT, MsgQuit, sizeof(MsgQuit) / sizeof(MsgQuit[0]));
213 LoadString(hInst, IDS_SOL_WIN, MsgWin, sizeof(MsgWin) / sizeof(MsgWin[0]));
214 LoadString(hInst, IDS_SOL_DEAL, MsgDeal, sizeof(MsgDeal) / sizeof(MsgDeal[0]));
215
216 LoadString(hInst, IDS_SOL_SCORE, szScore, sizeof(szScore) / sizeof(TCHAR));
217 LoadString(hInst, IDS_SOL_TIME, szTime, sizeof(szTime) / sizeof(TCHAR));
218
219 //Window class for the main application parent window
220 wndclass.style = 0;//CS_HREDRAW | CS_VREDRAW;
221 wndclass.lpfnWndProc = WndProc;
222 wndclass.cbClsExtra = 0;
223 wndclass.cbWndExtra = 0;
224 wndclass.hInstance = hInst;
226 wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
227 wndclass.hbrBackground = (HBRUSH)NULL;
229 wndclass.lpszClassName = szAppName;
230
231 RegisterClass(&wndclass);
232
233 ice.dwSize = sizeof(ice);
236
237 srand((unsigned)GetTickCount());//timeGetTime());
238
239// InitCardLib();
240
241 LoadSettings();
242
244
245 //Construct the path to our help file
246 MakePath(szHelpPath, MAX_PATH, _T(".hlp"));
247
248 hwnd = CreateWindow(szAppName, // window class name
249 szAppName, // window caption
251 ,//|WS_CLIPCHILDREN, // window style
252 CW_USEDEFAULT, // initial x position
253 CW_USEDEFAULT, // initial y position
254 0, // The real size will be computed in WndProc through WM_GETMINMAXINFO
255 0, // The real size will be computed in WndProc through WM_GETMINMAXINFO
256 NULL, // parent window handle
257 NULL, // use window class menu
258 hInst, // program instance handle
259 NULL); // creation parameters
260 if (hwnd == NULL)
261 return 1;
262
263 hwndMain = hwnd;
264
266
268
269 ShowWindow(hwnd, iCmdShow);
271
273
274 while(GetMessage(&msg, NULL,0,0))
275 {
276 if(!TranslateAccelerator(hwnd, hAccelTable, &msg))
277 {
280 }
281 }
282
283 SaveSettings();
284
285 return msg.wParam;
286}
#define msg(x)
Definition: auth_time.c:54
void SaveSettings(void)
Definition: settings.c:115
void LoadSettings(void)
Definition: settings.c:53
#define IDR_MENU1
Definition: resource.h:6
#define IDS_SOL_TIME
Definition: resource.h:49
#define IDS_SOL_DEAL
Definition: resource.h:47
#define IDS_SOL_SCORE
Definition: resource.h:48
#define IDS_SOL_ABOUT
Definition: resource.h:44
#define IDS_SOL_WIN
Definition: resource.h:46
#define IDS_SOL_QUIT
Definition: resource.h:45
#define IDS_SOL_NAME
Definition: resource.h:43
#define IDR_ACCELERATOR1
Definition: resource.h:7
#define IDI_SOLITAIRE
Definition: resource.h:4
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
HINSTANCE hInst
Definition: dxdiag.c:13
void __cdecl srand(_In_ unsigned int _Seed)
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define ICC_BAR_CLASSES
Definition: commctrl.h:60
TCHAR szAppName[128]
Definition: solitaire.cpp:18
HMENU hGameMenu
Definition: solitaire.cpp:16
TCHAR szHelpPath[MAX_PATH]
Definition: solitaire.cpp:10
TCHAR MsgDeal[128]
Definition: solitaire.cpp:24
TCHAR MsgAbout[128]
Definition: solitaire.cpp:22
TCHAR MsgWin[128]
Definition: solitaire.cpp:23
void MakePath(TCHAR *szDest, UINT nDestLen, const TCHAR *szExt)
Definition: solitaire.cpp:47
HINSTANCE hInstance
Definition: solitaire.cpp:15
HWND hwndMain
Definition: solitaire.cpp:13
void UpdateStatusBar(void)
Definition: solitaire.cpp:150
TCHAR szScore[64]
Definition: solitaire.cpp:19
TCHAR szTime[64]
Definition: solitaire.cpp:20
DWORD dwPrevMode
Definition: solitaire.cpp:30
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
Definition: solitaire.cpp:614
int GetScoreMode(void)
Definition: solitaire.cpp:130
TCHAR MsgQuit[128]
Definition: solitaire.cpp:21
HBRUSH hbrBackground
Definition: winuser.h:3170
HICON hIcon
Definition: winuser.h:3168
HINSTANCE hInstance
Definition: winuser.h:3167
HCURSOR hCursor
Definition: winuser.h:3169
int cbWndExtra
Definition: winuser.h:3166
UINT style
Definition: winuser.h:3163
LPCSTR lpszMenuName
Definition: winuser.h:3171
LPCSTR lpszClassName
Definition: winuser.h:3172
WNDPROC lpfnWndProc
Definition: winuser.h:3164
int cbClsExtra
Definition: winuser.h:3165
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define _T(x)
Definition: vfdio.h:22
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define IDC_ARROW
Definition: winuser.h:687
#define CreateWindow
Definition: winuser.h:5754
#define GetMessage
Definition: winuser.h:5790
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define LoadIcon
Definition: winuser.h:5813
BOOL WINAPI UpdateWindow(_In_ HWND)
#define LoadCursor
Definition: winuser.h:5812
#define CW_USEDEFAULT
Definition: winuser.h:225
#define LoadString
Definition: winuser.h:5819
#define RegisterClass
Definition: winuser.h:5836
#define DispatchMessage
Definition: winuser.h:5765
#define TranslateAccelerator
Definition: winuser.h:5860
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define LoadAccelerators
Definition: winuser.h:5810
HMENU WINAPI GetMenu(_In_ HWND)
char TCHAR
Definition: xmlstorage.h:189

◆ CardBackDlgProc()

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

Definition at line 521 of file solitaire.cpp.

525{
526 static PCARDBACK pCardBacks = NULL;
527
528 switch (uMsg)
529 {
530 case WM_INITDIALOG:
531 {
532 INT i, c;
533 SIZE_T size = sizeof(CARDBACK) * NUM_CARDBACKS;
534
535 pCardBacks = (PCARDBACK)HeapAlloc(GetProcessHeap(),
536 0,
537 size);
538
539 for (i = 0, c = CARDBACK_START; c <= CARDBACK_END; i++, c++)
540 {
541 pCardBacks[i].hSelf = GetDlgItem(hDlg, c);
542 pCardBacks[i].bSelected = FALSE;
543 pCardBacks[i].hdcNum = CARDBACK_RES_START + i;
544 pCardBacks[i].imgNum = i + 1;
545 pCardBacks[i].hOldProc = (WNDPROC)SetWindowLongPtr(pCardBacks[i].hSelf,
548
549 SetWindowLongPtr(pCardBacks[i].hSelf,
551 (LONG_PTR)&pCardBacks[i]);
552 }
553
554 return TRUE;
555 }
556
557 case WM_COMMAND:
558 if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
559 {
560 INT i, num = 0;
561 for (i = 0; i < NUM_CARDBACKS; i++)
562 {
563 if (pCardBacks[i].bSelected)
564 {
565 num = pCardBacks[i].imgNum;
566 }
567 }
568
569 EndDialog(hDlg, LOWORD(wParam) == IDOK ? num : FALSE);
570 HeapFree(GetProcessHeap(), 0, pCardBacks);
571 return TRUE;
572 }
573
574 if (HIWORD(wParam) == STN_CLICKED)
575 {
576 INT i;
577 RECT rc;
578 for (i = 0; i < NUM_CARDBACKS; i++)
579 {
580 if (pCardBacks[i].hSelf == (HWND)lParam)
581 {
582 pCardBacks[i].bSelected = TRUE;
583 }
584 else
585 pCardBacks[i].bSelected = FALSE;
586
587 GetClientRect(pCardBacks[i].hSelf, &rc);
588 InvalidateRect(pCardBacks[i].hSelf, &rc, TRUE);
589 }
590
591 break;
592 }
593 }
594
595 return FALSE;
596}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
GLsizeiptr size
Definition: glext.h:5919
const GLubyte * c
Definition: glext.h:8905
GLuint GLuint num
Definition: glext.h:9618
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
#define c
Definition: ke_i.h:80
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LOWORD(l)
Definition: pedump.c:82
struct _CardBack CARDBACK
LRESULT CALLBACK CardImageWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: solitaire.cpp:443
struct _CardBack * PCARDBACK
#define CARDBACK_END
Definition: solitaire.h:17
#define NUM_CARDBACKS
Definition: solitaire.h:18
#define CARDBACK_START
Definition: solitaire.h:16
#define CARDBACK_RES_START
Definition: solitaire.h:19
HWND hSelf
Definition: solitaire.cpp:38
BOOL bSelected
Definition: solitaire.cpp:42
INT imgNum
Definition: solitaire.cpp:41
WNDPROC hOldProc
Definition: solitaire.cpp:39
INT hdcNum
Definition: solitaire.cpp:40
#define SetWindowLongPtr
Definition: treelist.c:70
#define GWLP_WNDPROC
Definition: treelist.c:66
#define GWLP_USERDATA
Definition: treelist.c:63
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int32_t INT
Definition: typedefs.h:58
#define HIWORD(l)
Definition: typedefs.h:247
#define IDCANCEL
Definition: winuser.h:831
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:830
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2906
#define STN_CLICKED
Definition: winuser.h:2094
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by ShowDeckOptionsDlg().

◆ CardImageWndProc()

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

Definition at line 443 of file solitaire.cpp.

447{
450 static WNDPROC hOldProc = NULL;
451
452 if (!hOldProc && pCardBack)
453 hOldProc = pCardBack->hOldProc;
454
455 switch (msg)
456 {
457 case WM_PAINT:
458 {
459 HDC hdc;
460 PAINTSTRUCT ps;
461 HPEN hPen, hOldPen;
462 HBRUSH hBrush, hOldBrush;
463 RECT rc;
464
465 hdc = BeginPaint(hwnd, &ps);
466
467 if (pCardBack->bSelected)
468 {
469 hPen = CreatePen(PS_SOLID, 2, RGB(0,0,0));
470 }
471 else
472 {
474 hPen = CreatePen(PS_SOLID, 2, Face);
475 }
476
477 GetClientRect(hwnd, &rc);
478 hBrush = (HBRUSH)GetStockObject(NULL_BRUSH);
479 hOldPen = (HPEN)SelectObject(hdc, hPen);
480 hOldBrush = (HBRUSH)SelectObject(hdc, hBrush);
481
483 rc.left+1,
484 rc.top+1,
485 rc.right,
486 rc.bottom);
487
489 2,
490 2,
494 pCardBack->hdcNum * __cardwidth,
495 0,
498 SRCCOPY);
499
500 SelectObject(hdc, hOldPen);
501 SelectObject(hdc, hOldBrush);
502
503 EndPaint(hwnd, &ps);
504
505 break;
506 }
507
508 case WM_LBUTTONDOWN:
509 pCardBack->bSelected = pCardBack->bSelected ? FALSE : TRUE;
510 break;
511 }
512
513 return CallWindowProc(hOldProc,
514 hwnd,
515 msg,
516 wParam,
517 lParam);
518}
int __cardwidth
Definition: cardlib.cpp:25
int __cardheight
Definition: cardlib.cpp:26
HDC __hdcCardBitmaps
Definition: cardlib.cpp:18
#define RGB(r, g, b)
Definition: precomp.h:71
unsigned long DWORD
Definition: ntddk_ex.h:95
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
#define CARDBACK_OPTIONS_HEIGHT
Definition: solitaire.h:21
#define CARDBACK_OPTIONS_WIDTH
Definition: solitaire.h:20
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define GetWindowLongPtr
Definition: treelist.c:73
HGDIOBJ WINAPI GetStockObject(_In_ int)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
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)
#define SRCCOPY
Definition: wingdi.h:333
#define NULL_BRUSH
Definition: wingdi.h:901
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define PS_SOLID
Definition: wingdi.h:586
#define WM_PAINT
Definition: winuser.h:1620
DWORD WINAPI GetSysColor(_In_ int)
#define CallWindowProc
Definition: winuser.h:5735
#define WM_LBUTTONDOWN
Definition: winuser.h:1776
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define COLOR_3DFACE
Definition: winuser.h:929

Referenced by CardBackDlgProc().

◆ GetScoreMode()

int GetScoreMode ( void  )

Definition at line 130 of file solitaire.cpp.

131{
133 {
134 return SCORE_NONE;
135 }
136
138 {
139 return SCORE_STD;
140 }
141
143 {
144 return SCORE_VEGAS;
145 }
146
147 return 0;
148}
DWORD dwOptions
Definition: solitaire.cpp:25
#define SCORE_NONE
Definition: solitaire.h:44
#define OPTION_SCORE_STD
Definition: solitaire.h:14
#define OPTION_SCORE_VEGAS
Definition: solitaire.h:15
#define SCORE_STD
Definition: solitaire.h:45
#define SCORE_VEGAS
Definition: solitaire.h:46

Referenced by _tWinMain(), DeckClickProc(), NewGame(), OptionsDlgProc(), RowStackClickProc(), RowStackDropProc(), ShowGameOptionsDlg(), SuitStackAddProc(), SuitStackDropProc(), Undo(), UpdateStatusBar(), and WndProc().

◆ LoadSettings()

VOID LoadSettings ( VOID  )

Definition at line 56 of file solitaire.cpp.

57{
58 DWORD dwDisposition;
60 DWORD dwBack;
61 HKEY hKey;
62
64 _T("Software\\ReactOS\\Solitaire"),
65 0,
66 NULL,
69 NULL,
70 &hKey,
71 &dwDisposition))
72 return;
73
74 dwSize = sizeof(DWORD);
76 _T("Options"),
77 NULL,
78 NULL,
80 &dwSize);
81
82 dwSize = sizeof(DWORD);
84 _T("Back"),
85 NULL,
86 NULL,
87 (LPBYTE)&dwBack,
88 &dwSize);
89 SolWnd.SetBackCardIdx(dwBack);
90
92}
#define RegCloseKey(hKey)
Definition: registry.h:49
void SetBackCardIdx(UINT uBackIdx)
Definition: cardwindow.cpp:728
FxAutoRegKey hKey
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define KEY_READ
Definition: nt_native.h:1023
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define DWORD
Definition: nt_native.h:44
CardWindow SolWnd
Definition: solitaire.cpp:34
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define RegCreateKeyEx
Definition: winreg.h:501
#define RegQueryValueEx
Definition: winreg.h:524

◆ MakePath()

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

Definition at line 47 of file solitaire.cpp.

48{
49 TCHAR *ptr;
50
51 ptr = szDest + GetModuleFileName(GetModuleHandle(0), szDest, nDestLen) - 1;
52 while(*ptr-- != '.');
53 lstrcpy(ptr + 1, szExt);
54}
static PVOID ptr
Definition: dispmode.c:27
#define GetModuleHandle
Definition: winbase.h:3827
#define lstrcpy
Definition: winbase.h:3874
#define GetModuleFileName
Definition: winbase.h:3831

Referenced by _tWinMain().

◆ OptionsDlgProc()

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

Definition at line 289 of file solitaire.cpp.

290{
291 HWND hCtrl;
292
293 switch (uMsg)
294 {
295 case WM_INITDIALOG:
296 // For now, the Help dialog item is disabled because of lacking of HTML Help support
298
301
302 CheckDlgButton(hDlg,
305
306 CheckDlgButton(hDlg,
309
310 CheckDlgButton(hDlg,
313
314 hCtrl = GetDlgItem(hDlg, IDC_OPT_KEEPSCORE);
315
316 if (GetScoreMode() == SCORE_NONE)
317 {
319 EnableWindow(hCtrl, FALSE);
320 }
321 else if (GetScoreMode() == SCORE_STD)
322 {
324 EnableWindow(hCtrl, FALSE);
325 }
326 else if (GetScoreMode() == SCORE_VEGAS)
327 {
329 EnableWindow(hCtrl, TRUE);
330 }
331 return TRUE;
332
333 case WM_COMMAND:
334 switch(LOWORD(wParam))
335 {
336 case IDC_OPT_NOSCORE:
337 case IDC_OPT_STANDARD:
338 case IDC_OPT_VEGAS:
339 hCtrl = GetDlgItem(hDlg, IDC_OPT_KEEPSCORE);
340 if (wParam == IDC_OPT_VEGAS)
341 EnableWindow(hCtrl, TRUE);
342 else
343 EnableWindow(hCtrl, FALSE);
344 return TRUE;
345
346 case IDOK:
347 dwOptions &= ~OPTION_THREE_CARDS;
350
353 else
354 dwOptions &= ~OPTION_SHOW_STATUS;
355
358 else
359 dwOptions &= ~OPTION_SHOW_TIME;
360
363 else
364 dwOptions &= ~OPTION_KEEP_SCORE;
365
367 {
369 dwOptions &= ~OPTION_SCORE_VEGAS;
370 }
372 {
374 dwOptions &= ~OPTION_SCORE_STD;
375 }
377 {
380 }
381
383
384 EndDialog(hDlg, TRUE);
385 return TRUE;
386
387 case IDCANCEL:
388 EndDialog(hDlg, FALSE);
389 return TRUE;
390 }
391 break;
392 }
393 return FALSE;
394}
#define IDC_OPT_VEGAS
Definition: resource.h:25
#define IDC_OPT_STATUSBAR
Definition: resource.h:23
#define IDM_HELP_CONTENTS
Definition: resource.h:15
#define IDC_OPT_STANDARD
Definition: resource.h:24
#define IDC_OPT_DRAWONE
Definition: resource.h:20
#define IDC_OPT_DRAWTHREE
Definition: resource.h:21
#define IDC_OPT_SHOWTIME
Definition: resource.h:22
#define IDC_OPT_KEEPSCORE
Definition: resource.h:27
#define IDC_OPT_NOSCORE
Definition: resource.h:26
#define OPTION_SHOW_STATUS
Definition: solitaire.h:10
#define OPTION_THREE_CARDS
Definition: solitaire.h:11
#define OPTION_KEEP_SCORE
Definition: solitaire.h:13
#define OPTION_SHOW_TIME
Definition: solitaire.h:12
#define MF_BYCOMMAND
Definition: winuser.h:202
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define BST_UNCHECKED
Definition: winuser.h:199
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
BOOL WINAPI CheckRadioButton(_In_ HWND, _In_ int, _In_ int, _In_ int)
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define BST_CHECKED
Definition: winuser.h:197
#define MF_GRAYED
Definition: winuser.h:129

Referenced by MainDlgProc(), and ShowGameOptionsDlg().

◆ SaveSettings()

VOID SaveSettings ( VOID  )

Definition at line 94 of file solitaire.cpp.

95{
96 DWORD dwDisposition;
97 DWORD dwBack;
98 HKEY hKey;
99
101 _T("Software\\ReactOS\\Solitaire"),
102 0,
103 NULL,
105 KEY_WRITE,
106 NULL,
107 &hKey,
108 &dwDisposition))
109 return;
110
112 _T("Options"),
113 0,
114 REG_DWORD,
115 (CONST BYTE *)&dwOptions,
116 sizeof(DWORD));
117
118 dwBack = SolWnd.GetBackCardIdx();
120 _T("Back"),
121 0,
122 REG_DWORD,
123 (CONST BYTE *)&dwBack,
124 sizeof(DWORD));
125
127}
UINT GetBackCardIdx()
Definition: cardwindow.cpp:738
#define KEY_WRITE
Definition: nt_native.h:1031
#define CONST
Definition: pedump.c:81
#define REG_DWORD
Definition: sdbapi.c:596
#define RegSetValueEx
Definition: winreg.h:533
unsigned char BYTE
Definition: xxhash.c:193

◆ SetPlayTimer()

void SetPlayTimer ( void  )

Definition at line 172 of file solitaire.cpp.

173{
175 {
176 if (!PlayTimer)
177 {
179 }
180 }
181}
UINT_PTR PlayTimer
Definition: solitaire.cpp:32
#define IDT_PLAYTIMER
Definition: solitaire.h:33
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)

Referenced by CanDrop(), DeckClickProc(), PileDblClickProc(), PileRemoveProc(), RowStackDblClickProc(), RowStackDragProc(), RowStackDropProc(), SuitStackAddProc(), and SuitStackDropProc().

◆ SetUndoMenuState()

void SetUndoMenuState ( bool  enable)

Definition at line 183 of file solitaire.cpp.

184{
185 if (enable)
186 {
188 }
189 else
190 {
192 }
193}
#define IDM_GAME_UNDO
Definition: resource.h:11
GLboolean enable
Definition: glext.h:11120
#define MF_ENABLED
Definition: winuser.h:128

Referenced by ClearUndo(), and SetUndo().

◆ ShowDeckOptionsDlg()

VOID ShowDeckOptionsDlg ( HWND  hwnd)

Definition at line 599 of file solitaire.cpp.

600{
601 INT cardBack;
602
603 if ((cardBack = DialogBox(hInstance,
605 hwnd,
607 {
608 SolWnd.SetBackCardIdx(CARDBACK_RES_START + (cardBack - 1));
609 SolWnd.Redraw();
610 }
611}
#define IDD_CARDBACK
Definition: resource.h:28
void Redraw(void)
Definition: cardwindow.cpp:553
INT_PTR CALLBACK CardBackDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: solitaire.cpp:521
#define DialogBox
Definition: winuser.h:5761

Referenced by WndProc().

◆ ShowGameOptionsDlg()

VOID ShowGameOptionsDlg ( HWND  hwnd)

Definition at line 396 of file solitaire.cpp.

397{
398 DWORD dwOldOptions = dwOptions;
399 RECT rcMain, rcStatus;
400
401 int iOldScoreMode = GetScoreMode();
402
404 {
405 if (((dwOldOptions & OPTION_THREE_CARDS) != (dwOptions & OPTION_THREE_CARDS)) ||
406 ((dwOldOptions & OPTION_SHOW_TIME) != (dwOptions & OPTION_SHOW_TIME)) ||
407 (iOldScoreMode != GetScoreMode()))
408 NewGame();
409
410 if ((dwOldOptions & OPTION_SHOW_STATUS) != (dwOptions & OPTION_SHOW_STATUS))
411 {
412 int nWidth, nHeight, nStatusHeight;
413
414 GetClientRect(hwndMain, &rcMain);
415 nHeight = rcMain.bottom - rcMain.top;
416 nWidth = rcMain.right - rcMain.left;
417
419 {
420 RECT rc;
421
423 GetWindowRect(hwndStatus, &rcStatus);
424 nStatusHeight = rcStatus.bottom - rcStatus.top;
425 MoveWindow(SolWnd, 0, 0, nWidth, nHeight-nStatusHeight, TRUE);
426 MoveWindow(hwndStatus, 0, nHeight-nStatusHeight, nWidth, nHeight, TRUE);
427
428 // Force the window to process WM_GETMINMAXINFO again
430 SetWindowPos(hwndMain, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOMOVE | SWP_NOZORDER);
431 }
432 else
433 {
435 MoveWindow(SolWnd, 0, 0, nWidth, nHeight, TRUE);
436 }
437 }
438 }
439}
#define IDD_OPTIONS
Definition: resource.h:19
void NewGame(void)
Definition: solgame.cpp:18
HWND hwndStatus
Definition: solitaire.cpp:14
INT_PTR CALLBACK OptionsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: solitaire.cpp:289
#define SW_HIDE
Definition: winuser.h:768
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOMOVE
Definition: winuser.h:1244
#define SW_SHOW
Definition: winuser.h:775
#define SWP_NOZORDER
Definition: winuser.h:1247
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)

Referenced by WndProc().

◆ UpdateStatusBar()

void UpdateStatusBar ( void  )

Definition at line 150 of file solitaire.cpp.

151{
152 TCHAR szStatusText[128];
153 TCHAR szTempText[64];
154
155 ZeroMemory(szStatusText, sizeof(szStatusText));
156
157 if (GetScoreMode() != SCORE_NONE)
158 {
159 _stprintf(szStatusText, szScore, lScore);
160 _tcscat(szStatusText, _T(" "));
161 }
162
164 {
165 _stprintf(szTempText, szTime, dwTime);
166 _tcscat(szStatusText, szTempText);
167 }
168
170}
#define _tcscat
Definition: tchar.h:622
#define _stprintf
Definition: utility.h:124
#define SBT_NOBORDERS
Definition: commctrl.h:1971
#define SB_SETTEXT
Definition: commctrl.h:1949
DWORD dwTime
Definition: solitaire.cpp:27
long lScore
Definition: solitaire.cpp:31
#define ZeroMemory
Definition: winbase.h:1712
LONG_PTR LPARAM
Definition: windef.h:208
#define SendMessage
Definition: winuser.h:5843
CHAR * LPTSTR
Definition: xmlstorage.h:192

Referenced by _tWinMain(), DeckClickProc(), LrgCellWndProc(), NewGame(), OnVScroll(), OptionsDlgProc(), RowStackClickProc(), RowStackDropProc(), SetCaretXY(), SuitStackAddProc(), SuitStackDropProc(), Undo(), and WndProc().

◆ WndProc()

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

FIXME: Reenable this check once menu items are correctly disabled when no event is selected, etc. MessageBoxW(hWnd, L"No selected items!", szTitle, MB_OK | MB_ICONERROR);

Definition at line 614 of file solitaire.cpp.

615{
616 static int nWidth, nHeight, nStatusHeight;
617
618 switch(iMsg)
619 {
620 case WM_CREATE:
621 {
622 int parts[] = { 150, -1 };
623 RECT rcStatus;
624
625 // For now, the Help dialog item is disabled because of lacking of HTML Help support
627
629
630 //SendMessage(hwndStatus, SB_SIMPLE, (WPARAM)TRUE, 0);
631
634
635 SolWnd.Create(hwnd, 0, WS_CHILD | WS_VISIBLE, 0, 0, 100, 100);
636
637 CreateSol();
638
639 // The status bar height is fixed and needed later in WM_SIZE and WM_GETMINMAXINFO
640 // Force the window to process WM_GETMINMAXINFO again
641 GetWindowRect(hwndStatus, &rcStatus);
642 nStatusHeight = rcStatus.bottom - rcStatus.top;
643
644 // Hide status bar if options say so
646 {
648 }
649
651
652 NewGame();
653
655
656 return 0;
657 }
658
659 case WM_DESTROY:
661 return 0;
662
663 case WM_TIMER:
664 if (!fGameStarted)
665 {
667 PlayTimer = 0;
668 }
669 else if (dwOptions & OPTION_SHOW_TIME)
670 {
671 if (((dwTime + 1) % 10 == 0) && (GetScoreMode() == SCORE_STD))
672 {
673 lScore = lScore >= 2 ? lScore - 2 : 0;
674 }
675
676 dwTime++;
677 }
678
680 return 0;
681
682 case WM_SIZE:
683 nWidth = LOWORD(lParam);
684 nHeight = HIWORD(lParam);
685
687 {
688 MoveWindow(SolWnd, 0, 0, nWidth, nHeight - nStatusHeight, TRUE);
689 MoveWindow(hwndStatus, 0, nHeight - nStatusHeight, nWidth, nStatusHeight, TRUE);
690 }
691 else
692 {
693 MoveWindow(SolWnd, 0, 0, nWidth, nHeight, TRUE);
694 }
695 //parts[0] = nWidth - 256;
696 //SendMessage(hwndStatus, SB_SETPARTS, 2, (LPARAM)parts);
697 return 0;
698
699 case WM_GETMINMAXINFO:
700 {
701 MINMAXINFO *mmi;
702
703 mmi = (MINMAXINFO *)lParam;
707 Y_BORDER +
712 Y_BORDER +
713 (dwOptions & OPTION_SHOW_STATUS ? nStatusHeight : 0);
714 return 0;
715 }
716
717 case WM_COMMAND:
718 switch(LOWORD(wParam))
719 {
720 case IDM_GAME_NEW:
721 //simulate a button click on the new button..
722 NewGame();
723 return 0;
724
725 case IDM_GAME_UNDO:
726 Undo();
727 return 0;
728
729 case IDM_GAME_DECK:
731 return 0;
732
733 case IDM_GAME_OPTIONS:
735 return 0;
736
738 WinHelp(hwnd, szHelpPath, HELP_CONTENTS, 0);//HELP_KEY, (DWORD)"How to play");
739 return 0;
740
741 case IDM_HELP_ABOUT:
744 return 0;
745
746 case IDM_GAME_EXIT:
747 PostMessage(hwnd, WM_CLOSE, 0, 0);
748 return 0;
749 }
750
751 return 0;
752
753 case WM_CLOSE:
754 if (fGameStarted == false)
755 {
757 return 0;
758 }
759 else
760 {
761 int ret;
762
764 if (ret == IDYES)
765 {
768 }
769 }
770 return 0;
771 }
772
773 return DefWindowProc (hwnd, iMsg, wParam, lParam);
774}
#define IDM_HELP_ABOUT
Definition: resource.h:387
#define IDM_GAME_NEW
Definition: resource.h:10
#define IDM_GAME_DECK
Definition: resource.h:12
#define IDM_GAME_EXIT
Definition: resource.h:14
#define IDM_GAME_OPTIONS
Definition: resource.h:13
BOOL Create(HWND hwndParent, DWORD dwExStyle, DWORD dwStyle, int x, int y, int width, int height)
Definition: cardwindow.cpp:109
static const D3D_BLOB_PART parts[]
Definition: blob.c:76
#define WS_CHILD
Definition: pedump.c:617
#define WS_VISIBLE
Definition: pedump.c:620
#define CreateStatusWindow
Definition: commctrl.h:1933
#define CCS_BOTTOM
Definition: commctrl.h:2244
#define SB_SETPARTS
Definition: commctrl.h:1954
#define SBARS_SIZEGRIP
Definition: commctrl.h:1923
#define DefWindowProc
Definition: ros2win.h:31
#define ShellAbout
Definition: shellapi.h:692
int yRowStackCardOffset
Definition: solcreate.cpp:10
void CreateSol()
Definition: solcreate.cpp:12
bool fGameStarted
Definition: solgame.cpp:15
VOID ShowDeckOptionsDlg(HWND hwnd)
Definition: solitaire.cpp:599
VOID ShowGameOptionsDlg(HWND hwnd)
Definition: solitaire.cpp:396
DWORD dwAppStartTime
Definition: solitaire.cpp:12
#define Y_BORDER
Definition: solitaire.h:53
#define NUM_ROW_STACKS
Definition: solitaire.h:38
#define X_BORDER
Definition: solitaire.h:49
#define X_ROWSTACK_BORDER
Definition: solitaire.h:51
void Undo(void)
Definition: solundo.cpp:53
#define Y_ROWSTACK_BORDER
Definition: solitaire.h:55
POINT ptMinTrackSize
Definition: winuser.h:3630
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
int ret
#define WM_CLOSE
Definition: winuser.h:1621
#define WinHelp
Definition: winuser.h:5864
#define HELP_QUIT
Definition: winuser.h:2414
#define WM_CREATE
Definition: winuser.h:1608
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_SIZE
Definition: winuser.h:1611
#define HELP_CONTENTS
Definition: winuser.h:2405
#define SM_CYMENU
Definition: winuser.h:976
#define MB_YESNO
Definition: winuser.h:817
#define WM_GETMINMAXINFO
Definition: winuser.h:1640
#define WM_TIMER
Definition: winuser.h:1742
#define PostMessage
Definition: winuser.h:5832
#define MB_ICONQUESTION
Definition: winuser.h:789
#define MessageBox
Definition: winuser.h:5822
#define WM_DESTROY
Definition: winuser.h:1609
#define IDYES
Definition: winuser.h:835
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
BOOL WINAPI DestroyWindow(_In_ HWND)
#define SM_CYCAPTION
Definition: winuser.h:963
int WINAPI GetSystemMetrics(_In_ int)

Referenced by _tWinMain(), CreateCallProc(), DispatchMessageA(), DispatchMessageW(), IntCallMessageProc(), IntCallWindowProcA(), IntCallWindowProcW(), IntCreateClass(), IntSetClassWndProc(), and UserSearchForCallProc().

Variable Documentation

◆ dwAppStartTime

DWORD dwAppStartTime

Definition at line 12 of file solitaire.cpp.

Referenced by WndProc().

◆ dwOptions

Definition at line 25 of file solitaire.cpp.

Referenced by AboutProtocol_Abort(), AboutProtocol_LockRequest(), AboutProtocol_Terminate(), BindProtocol_Abort(), BindProtocol_LockRequest(), BindProtocol_Terminate(), ATL::CRegKey::Create(), CreateHKCRKey(), CreateNestedKey(), DeckClickProc(), DuplicateConsoleHandle(), DuplicateHandle(), FileProtocol_Abort(), FileProtocol_LockRequest(), FileProtocol_Terminate(), FilterConnectCommunicationPort(), FixIfOneCardLeft(), FtpProtocol_Abort(), FtpProtocol_LockRequest(), FtpProtocol_Terminate(), GetScoreMode(), GopherProtocol_Abort(), GopherProtocol_LockRequest(), GopherProtocol_Terminate(), GUIDisplayStatusMessage(), HitTestThemeBackground(), HttpProtocol_Abort(), HttpProtocol_LockRequest(), HttpProtocol_Terminate(), ITSProtocol_Abort(), ITSProtocol_LockRequest(), ITSProtocol_Terminate(), IUnknown_AddOptions(), LoadSettings(), MimeFilterProtocol_Abort(), MimeFilterProtocol_LockRequest(), MimeFilterProtocol_Terminate(), MimeHtmlProtocol_Abort(), MimeHtmlProtocol_LockRequest(), MimeHtmlProtocol_Terminate(), MimeProtocol_LockRequest(), MimeProtocol_Terminate(), MkProtocol_Abort(), MkProtocol_LockRequest(), MkProtocol_Terminate(), MSI_OpenPackageW(), MsiAdvertiseProductExA(), MsiAdvertiseProductExW(), MsiGetFileHashA(), MsiGetFileHashW(), MsiOpenPackageExA(), MsiOpenPackageExW(), MsiSourceListAddMediaDiskA(), MsiSourceListAddMediaDiskW(), MsiSourceListAddSourceExA(), MsiSourceListAddSourceExW(), MsiSourceListClearAllExA(), MsiSourceListClearAllExW(), MsiSourceListClearSourceA(), MsiSourceListClearSourceW(), MsiSourceListEnumMediaDisksA(), MsiSourceListEnumMediaDisksW(), MsiSourceListEnumSourcesA(), MsiSourceListEnumSourcesW(), MsiSourceListGetInfoA(), MsiSourceListGetInfoW(), MsiSourceListSetInfoA(), MsiSourceListSetInfoW(), NewGame(), OpenSourceKey(), OptionsDlgProc(), PileRemoveProc(), Protocol_Abort(), Protocol_Terminate(), ProtocolEmul_LockRequest(), ProtocolEmul_Terminate(), ProtocolHandler_Abort(), ProtocolHandler_LockRequest(), ProtocolHandler_Terminate(), RefreshPolicyEx(), RegCreateKeyExA(), RegCreateKeyExW(), RegOpenUserClassesRoot(), ResProtocol_Abort(), ResProtocol_LockRequest(), ResProtocol_Terminate(), SaveSettings(), SetPlayTimer(), SHMapHandle(), ShowGameOptionsDlg(), SuitStackAddProc(), test_CopyBindInfo(), test_pack_INTERNET_AUTH_NOTIFY_DATA(), test_pack_RemBINDINFO(), TUIDisplayStatusMessage(), UpdateStatusBar(), WlxDisplayStatusMessage(), and WndProc().

◆ dwPrevMode

DWORD dwPrevMode

Definition at line 30 of file solitaire.cpp.

Referenced by _tWinMain(), and NewGame().

◆ dwTime

◆ dwWasteCount

DWORD dwWasteCount

Definition at line 28 of file solitaire.cpp.

Referenced by DeckClickProc(), and NewGame().

◆ dwWasteTreshold

DWORD dwWasteTreshold

Definition at line 29 of file solitaire.cpp.

Referenced by DeckClickProc(), and NewGame().

◆ hGameMenu

HMENU hGameMenu

Definition at line 16 of file solitaire.cpp.

Referenced by _tWinMain(), and SetUndoMenuState().

◆ hInstance

HINSTANCE hInstance

Definition at line 15 of file solitaire.cpp.

Referenced by _tWinMain(), ShowDeckOptionsDlg(), ShowGameOptionsDlg(), and WndProc().

◆ hwndMain

◆ hwndStatus

◆ lScore

◆ MsgAbout

TCHAR MsgAbout[128]

Definition at line 22 of file solitaire.cpp.

Referenced by _tWinMain(), and WndProc().

◆ MsgDeal

TCHAR MsgDeal[128]

Definition at line 24 of file solitaire.cpp.

Referenced by _tWinMain().

◆ MsgQuit

TCHAR MsgQuit[128]

Definition at line 21 of file solitaire.cpp.

Referenced by _tWinMain(), and WndProc().

◆ MsgWin

TCHAR MsgWin[128]

Definition at line 23 of file solitaire.cpp.

Referenced by _tWinMain().

◆ PlayTimer

UINT_PTR PlayTimer = 0

Definition at line 32 of file solitaire.cpp.

Referenced by SetPlayTimer(), SuitStackAddProc(), and WndProc().

◆ SolWnd

◆ szAppName

◆ szHelpPath

TCHAR szHelpPath[MAX_PATH]

Definition at line 10 of file solitaire.cpp.

Referenced by _tWinMain(), and WndProc().

◆ szScore

TCHAR szScore[64]

Definition at line 19 of file solitaire.cpp.

Referenced by _tWinMain(), and UpdateStatusBar().

◆ szTime