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