--- /dev/null
+#include <windows.h>\r
+#include <commctrl.h>\r
+#include <tchar.h>\r
+#include "resource.h"\r
+#include "cardlib/cardlib.h"\r
+\r
+#include "solitaire.h"\r
+\r
+TCHAR szHelpPath[MAX_PATH];\r
+\r
+DWORD dwAppStartTime;\r
+HWND hwndMain;\r
+HWND hwndStatus;\r
+HINSTANCE hInstance;\r
+\r
+TCHAR szAppName[] = _T("Solitaire");\r
+\r
+CardWindow SolWnd;\r
+\r
+LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);\r
+\r
+void MakePath(TCHAR *szDest, UINT nDestLen, TCHAR *szExt)\r
+{\r
+ TCHAR *ptr;\r
+ \r
+ ptr = szDest + GetModuleFileName(GetModuleHandle(0), szDest, nDestLen) - 1;\r
+ while(*ptr-- != '.');\r
+ lstrcpy(ptr + 1, szExt);\r
+}\r
+\r
+//\r
+// Main entry point\r
+//\r
+int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, PSTR szCmdLine, int iCmdShow)\r
+{\r
+ HWND hwnd;\r
+ MSG msg;\r
+ WNDCLASSEX wndclass;\r
+ INITCOMMONCONTROLSEX ice;\r
+ HACCEL hAccelTable; \r
+\r
+ hInstance = hInst;\r
+\r
+ //Window class for the main application parent window\r
+ wndclass.cbSize = sizeof(wndclass);\r
+ wndclass.style = 0;//CS_HREDRAW | CS_VREDRAW;\r
+ wndclass.lpfnWndProc = WndProc;\r
+ wndclass.cbClsExtra = 0;\r
+ wndclass.cbWndExtra = 0;\r
+ wndclass.hInstance = hInst;\r
+ wndclass.hIcon = LoadIcon (hInst, MAKEINTRESOURCE(IDI_ICON1));\r
+ wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);\r
+ wndclass.hbrBackground = (HBRUSH)NULL;\r
+ wndclass.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);\r
+ wndclass.lpszClassName = szAppName;\r
+ wndclass.hIconSm = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 16, 16, 0);\r
+\r
+ RegisterClassEx(&wndclass);\r
+\r
+ ice.dwSize = sizeof(ice);\r
+ ice.dwICC = ICC_BAR_CLASSES;\r
+ InitCommonControlsEx(&ice);\r
+\r
+ srand((unsigned)GetTickCount());//timeGetTime());\r
+\r
+// InitCardLib();\r
+\r
+// LoadSettings();\r
+\r
+ //Construct the path to our help file\r
+ MakePath(szHelpPath, MAX_PATH, _T(".hlp"));\r
+ \r
+ hwnd = CreateWindow(szAppName, // window class name\r
+ szAppName, // window caption\r
+ WS_OVERLAPPEDWINDOW\r
+ ,//|WS_CLIPCHILDREN, // window style\r
+ CW_USEDEFAULT, // initial x position\r
+ CW_USEDEFAULT, // initial y position\r
+ CW_USEDEFAULT, // initial x size\r
+ CW_USEDEFAULT, // initial y size\r
+ NULL, // parent window handle\r
+ NULL, // use window class menu\r
+ hInst, // program instance handle\r
+ NULL); // creation parameters\r
+\r
+ hwndMain = hwnd;\r
+\r
+ ShowWindow(hwnd, iCmdShow);\r
+ UpdateWindow(hwnd);\r
+\r
+ hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1));\r
+\r
+ while(GetMessage(&msg, NULL,0,0))\r
+ {\r
+ if(!TranslateAccelerator(hwnd, hAccelTable, &msg))\r
+ {\r
+ TranslateMessage(&msg);\r
+ DispatchMessage(&msg);\r
+ }\r
+ }\r
+\r
+// SaveSettings();\r
+\r
+ return msg.wParam;\r
+}\r
+\r
+\r
+//-----------------------------------------------------------------------------\r
+LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)\r
+{\r
+ static int nWidth, nHeight;\r
+ int nStatusHeight = 0;//20;\r
+ int parts[] = { 100, -1 };\r
+ UINT ret;\r
+\r
+ MINMAXINFO *mmi;\r
+\r
+ switch(iMsg)\r
+ {\r
+ case WM_CREATE:\r
+ hwndStatus = CreateStatusWindow(WS_CHILD | WS_VISIBLE | CCS_BOTTOM | SBARS_SIZEGRIP, "Ready", hwnd, 0);\r
+ \r
+ //SendMessage(hwndStatus, SB_SIMPLE, (WPARAM)TRUE, 0);\r
+\r
+ SendMessage(hwndStatus, SB_SETPARTS, 2, (LPARAM)parts); \r
+ SendMessage(hwndStatus, SB_SETTEXT, 0 | SBT_NOBORDERS, (LPARAM)"");\r
+\r
+ ShowWindow(hwndStatus, SW_HIDE);\r
+\r
+ SolWnd.Create(hwnd, WS_EX_CLIENTEDGE, WS_CHILD|WS_VISIBLE, 0, 0, 0, 0);\r
+\r
+ CreateSol();\r
+\r
+ NewGame();\r
+\r
+ dwAppStartTime = GetTickCount();\r
+\r
+ return 0;\r
+\r
+ case WM_DESTROY:\r
+ PostQuitMessage(0);\r
+ return 0;\r
+\r
+ case WM_SIZE:\r
+ nWidth = LOWORD(lParam);\r
+ nHeight = HIWORD(lParam);\r
+\r
+ MoveWindow(SolWnd, 0, 0, nWidth, nHeight-nStatusHeight, TRUE);\r
+ //MoveWindow(hwndStatus, 0, nHeight-nStatusHeight, nWidth, nHeight, TRUE);\r
+ //parts[0] = nWidth - 256;\r
+ //SendMessage(hwndStatus, SB_SETPARTS, 2, (LPARAM)parts); \r
+\r
+ return 0;\r
+\r
+ case WM_GETMINMAXINFO:\r
+ mmi = (MINMAXINFO *)lParam; \r
+ mmi->ptMinTrackSize.x = 600;\r
+ mmi->ptMinTrackSize.y = 400;\r
+\r
+ return 0;\r
+\r
+ case WM_COMMAND:\r
+ \r
+ switch(LOWORD(wParam))\r
+ {\r
+ case IDM_GAME_NEW:\r
+ //simulate a button click on the new button..\r
+ NewGame();\r
+ return 0;\r
+\r
+ case IDM_GAME_DECK:\r
+ //ShowDeckOptionsDlg(hwnd);\r
+ return 0;\r
+\r
+ case IDM_GAME_OPTIONS:\r
+ //ShowGameOptionsDlg(hwnd);\r
+ return 0;\r
+\r
+ case IDM_HELP_CONTENTS:\r
+\r
+ WinHelp(hwnd, szHelpPath, HELP_CONTENTS, 0);//HELP_KEY, (DWORD)"How to play");\r
+ \r
+ return 0;\r
+\r
+ case IDM_HELP_ABOUT:\r
+ MessageBox(hwnd, _T("Solitare by J Brown\r\n\r\nCardLib version 1.0."), szAppName, MB_OK|MB_ICONINFORMATION);\r
+\r
+ return 0;\r
+\r
+ case IDM_GAME_EXIT:\r
+ PostMessage(hwnd, WM_CLOSE, 0, 0);\r
+ return 0;\r
+ }\r
+\r
+ return 0;\r
+\r
+ case WM_CLOSE:\r
+ \r
+ ret = IDOK;\r
+\r
+ if(fGameStarted)\r
+ {\r
+ ret = MessageBox(hwnd, _T("Quit the current game?"), szAppName, MB_OKCANCEL|MB_ICONQUESTION);\r
+ }\r
+\r
+ if(ret == IDOK)\r
+ {\r
+ WinHelp(hwnd, szHelpPath, HELP_QUIT, 0);\r
+ DestroyWindow(hwnd);\r
+ }\r
+\r
+ return 0;\r
+ }\r
+\r
+ return DefWindowProc (hwnd, iMsg, wParam, lParam);\r
+}\r
+\r