7 #include "cardlib/cardlib.h"
11 TCHAR szHelpPath
[MAX_PATH
];
18 TCHAR szAppName
[] = _T("Solitaire");
22 LRESULT CALLBACK
WndProc (HWND hwnd
, UINT iMsg
, WPARAM wParam
, LPARAM lParam
);
24 void MakePath(TCHAR
*szDest
, UINT nDestLen
, TCHAR
*szExt
)
28 ptr
= szDest
+ GetModuleFileName(GetModuleHandle(0), szDest
, nDestLen
) - 1;
30 lstrcpy(ptr
+ 1, szExt
);
33 int main ( int argc
, char** argv
)
35 return WinMain ( NULL
, NULL
, NULL
, SW_SHOW
);
41 int WINAPI
WinMain (HINSTANCE hInst
, HINSTANCE hPrev
, PSTR szCmdLine
, int iCmdShow
)
46 INITCOMMONCONTROLSEX ice
;
51 //Window class for the main application parent window
52 wndclass
.cbSize
= sizeof(wndclass
);
53 wndclass
.style
= 0;//CS_HREDRAW | CS_VREDRAW;
54 wndclass
.lpfnWndProc
= WndProc
;
55 wndclass
.cbClsExtra
= 0;
56 wndclass
.cbWndExtra
= 0;
57 wndclass
.hInstance
= hInst
;
58 wndclass
.hIcon
= LoadIcon (hInst
, MAKEINTRESOURCE(IDI_ICON1
));
59 wndclass
.hCursor
= LoadCursor (NULL
, IDC_ARROW
);
60 wndclass
.hbrBackground
= (HBRUSH
)NULL
;
61 wndclass
.lpszMenuName
= MAKEINTRESOURCE(IDR_MENU1
);
62 wndclass
.lpszClassName
= szAppName
;
63 wndclass
.hIconSm
= (HICON
)LoadImage(hInst
, MAKEINTRESOURCE(IDI_ICON1
), IMAGE_ICON
, 16, 16, 0);
65 RegisterClassEx(&wndclass
);
67 ice
.dwSize
= sizeof(ice
);
68 ice
.dwICC
= ICC_BAR_CLASSES
;
69 InitCommonControlsEx(&ice
);
71 srand((unsigned)GetTickCount());//timeGetTime());
77 //Construct the path to our help file
78 MakePath(szHelpPath
, MAX_PATH
, _T(".hlp"));
80 hwnd
= CreateWindow(szAppName
, // window class name
81 szAppName
, // window caption
83 ,//|WS_CLIPCHILDREN, // window style
84 CW_USEDEFAULT
, // initial x position
85 CW_USEDEFAULT
, // initial y position
86 CW_USEDEFAULT
, // initial x size
87 CW_USEDEFAULT
, // initial y size
88 NULL
, // parent window handle
89 NULL
, // use window class menu
90 hInst
, // program instance handle
91 NULL
); // creation parameters
95 ShowWindow(hwnd
, iCmdShow
);
98 hAccelTable
= LoadAccelerators(hInstance
, MAKEINTRESOURCE(IDR_ACCELERATOR1
));
100 while(GetMessage(&msg
, NULL
,0,0))
102 if(!TranslateAccelerator(hwnd
, hAccelTable
, &msg
))
104 TranslateMessage(&msg
);
105 DispatchMessage(&msg
);
115 //-----------------------------------------------------------------------------
116 LRESULT CALLBACK
WndProc (HWND hwnd
, UINT iMsg
, WPARAM wParam
, LPARAM lParam
)
118 static int nWidth
, nHeight
;
119 int nStatusHeight
= 0;//20;
120 int parts
[] = { 100, -1 };
128 hwndStatus
= CreateStatusWindow(WS_CHILD
| WS_VISIBLE
| CCS_BOTTOM
| SBARS_SIZEGRIP
, "Ready", hwnd
, 0);
130 //SendMessage(hwndStatus, SB_SIMPLE, (WPARAM)TRUE, 0);
132 SendMessage(hwndStatus
, SB_SETPARTS
, 2, (LPARAM
)parts
);
133 SendMessage(hwndStatus
, SB_SETTEXT
, 0 | SBT_NOBORDERS
, (LPARAM
)"");
135 ShowWindow(hwndStatus
, SW_HIDE
);
137 SolWnd
.Create(hwnd
, WS_EX_CLIENTEDGE
, WS_CHILD
|WS_VISIBLE
, 0, 0, 0, 0);
143 dwAppStartTime
= GetTickCount();
152 nWidth
= LOWORD(lParam
);
153 nHeight
= HIWORD(lParam
);
155 MoveWindow(SolWnd
, 0, 0, nWidth
, nHeight
-nStatusHeight
, TRUE
);
156 //MoveWindow(hwndStatus, 0, nHeight-nStatusHeight, nWidth, nHeight, TRUE);
157 //parts[0] = nWidth - 256;
158 //SendMessage(hwndStatus, SB_SETPARTS, 2, (LPARAM)parts);
162 case WM_GETMINMAXINFO
:
163 mmi
= (MINMAXINFO
*)lParam
;
164 mmi
->ptMinTrackSize
.x
= 600;
165 mmi
->ptMinTrackSize
.y
= 400;
171 switch(LOWORD(wParam
))
174 //simulate a button click on the new button..
179 //ShowDeckOptionsDlg(hwnd);
182 case IDM_GAME_OPTIONS
:
183 //ShowGameOptionsDlg(hwnd);
186 case IDM_HELP_CONTENTS
:
188 WinHelp(hwnd
, szHelpPath
, HELP_CONTENTS
, 0);//HELP_KEY, (DWORD)"How to play");
193 MessageBox(hwnd
, _T("Solitaire by J Brown\r\n\r\nCardLib version 1.0."), szAppName
, MB_OK
|MB_ICONINFORMATION
);
198 PostMessage(hwnd
, WM_CLOSE
, 0, 0);
210 ret
= MessageBox(hwnd
, _T("Quit the current game?"), szAppName
, MB_OKCANCEL
|MB_ICONQUESTION
);
215 WinHelp(hwnd
, szHelpPath
, HELP_QUIT
, 0);
222 return DefWindowProc (hwnd
, iMsg
, wParam
, lParam
);