5 #include "cardlib/cardlib.h"
9 TCHAR szHelpPath
[MAX_PATH
];
16 TCHAR szAppName
[] = _T("Solitaire");
20 LRESULT CALLBACK
WndProc (HWND hwnd
, UINT iMsg
, WPARAM wParam
, LPARAM lParam
);
22 void MakePath(TCHAR
*szDest
, UINT nDestLen
, TCHAR
*szExt
)
26 ptr
= szDest
+ GetModuleFileName(GetModuleHandle(0), szDest
, nDestLen
) - 1;
28 lstrcpy(ptr
+ 1, szExt
);
34 int WINAPI
WinMain (HINSTANCE hInst
, HINSTANCE hPrev
, PSTR szCmdLine
, int iCmdShow
)
39 INITCOMMONCONTROLSEX ice
;
44 //Window class for the main application parent window
45 wndclass
.cbSize
= sizeof(wndclass
);
46 wndclass
.style
= 0;//CS_HREDRAW | CS_VREDRAW;
47 wndclass
.lpfnWndProc
= WndProc
;
48 wndclass
.cbClsExtra
= 0;
49 wndclass
.cbWndExtra
= 0;
50 wndclass
.hInstance
= hInst
;
51 wndclass
.hIcon
= LoadIcon (hInst
, MAKEINTRESOURCE(IDI_ICON1
));
52 wndclass
.hCursor
= LoadCursor (NULL
, IDC_ARROW
);
53 wndclass
.hbrBackground
= (HBRUSH
)NULL
;
54 wndclass
.lpszMenuName
= MAKEINTRESOURCE(IDR_MENU1
);
55 wndclass
.lpszClassName
= szAppName
;
56 wndclass
.hIconSm
= (HICON
)LoadImage(hInst
, MAKEINTRESOURCE(IDI_ICON1
), IMAGE_ICON
, 16, 16, 0);
58 RegisterClassEx(&wndclass
);
60 ice
.dwSize
= sizeof(ice
);
61 ice
.dwICC
= ICC_BAR_CLASSES
;
62 InitCommonControlsEx(&ice
);
64 srand((unsigned)GetTickCount());//timeGetTime());
70 //Construct the path to our help file
71 MakePath(szHelpPath
, MAX_PATH
, _T(".hlp"));
73 hwnd
= CreateWindow(szAppName
, // window class name
74 szAppName
, // window caption
76 ,//|WS_CLIPCHILDREN, // window style
77 CW_USEDEFAULT
, // initial x position
78 CW_USEDEFAULT
, // initial y position
79 CW_USEDEFAULT
, // initial x size
80 CW_USEDEFAULT
, // initial y size
81 NULL
, // parent window handle
82 NULL
, // use window class menu
83 hInst
, // program instance handle
84 NULL
); // creation parameters
88 ShowWindow(hwnd
, iCmdShow
);
91 hAccelTable
= LoadAccelerators(hInstance
, MAKEINTRESOURCE(IDR_ACCELERATOR1
));
93 while(GetMessage(&msg
, NULL
,0,0))
95 if(!TranslateAccelerator(hwnd
, hAccelTable
, &msg
))
97 TranslateMessage(&msg
);
98 DispatchMessage(&msg
);
108 //-----------------------------------------------------------------------------
109 LRESULT CALLBACK
WndProc (HWND hwnd
, UINT iMsg
, WPARAM wParam
, LPARAM lParam
)
111 static int nWidth
, nHeight
;
112 int nStatusHeight
= 0;//20;
113 int parts
[] = { 100, -1 };
121 hwndStatus
= CreateStatusWindow(WS_CHILD
| WS_VISIBLE
| CCS_BOTTOM
| SBARS_SIZEGRIP
, "Ready", hwnd
, 0);
123 //SendMessage(hwndStatus, SB_SIMPLE, (WPARAM)TRUE, 0);
125 SendMessage(hwndStatus
, SB_SETPARTS
, 2, (LPARAM
)parts
);
126 SendMessage(hwndStatus
, SB_SETTEXT
, 0 | SBT_NOBORDERS
, (LPARAM
)"");
128 ShowWindow(hwndStatus
, SW_HIDE
);
130 SolWnd
.Create(hwnd
, WS_EX_CLIENTEDGE
, WS_CHILD
|WS_VISIBLE
, 0, 0, 0, 0);
136 dwAppStartTime
= GetTickCount();
145 nWidth
= LOWORD(lParam
);
146 nHeight
= HIWORD(lParam
);
148 MoveWindow(SolWnd
, 0, 0, nWidth
, nHeight
-nStatusHeight
, TRUE
);
149 //MoveWindow(hwndStatus, 0, nHeight-nStatusHeight, nWidth, nHeight, TRUE);
150 //parts[0] = nWidth - 256;
151 //SendMessage(hwndStatus, SB_SETPARTS, 2, (LPARAM)parts);
155 case WM_GETMINMAXINFO
:
156 mmi
= (MINMAXINFO
*)lParam
;
157 mmi
->ptMinTrackSize
.x
= 600;
158 mmi
->ptMinTrackSize
.y
= 400;
164 switch(LOWORD(wParam
))
167 //simulate a button click on the new button..
172 //ShowDeckOptionsDlg(hwnd);
175 case IDM_GAME_OPTIONS
:
176 //ShowGameOptionsDlg(hwnd);
179 case IDM_HELP_CONTENTS
:
181 WinHelp(hwnd
, szHelpPath
, HELP_CONTENTS
, 0);//HELP_KEY, (DWORD)"How to play");
186 MessageBox(hwnd
, _T("Solitare by J Brown\r\n\r\nCardLib version 1.0."), szAppName
, MB_OK
|MB_ICONINFORMATION
);
191 PostMessage(hwnd
, WM_CLOSE
, 0, 0);
203 ret
= MessageBox(hwnd
, _T("Quit the current game?"), szAppName
, MB_OKCANCEL
|MB_ICONQUESTION
);
208 WinHelp(hwnd
, szHelpPath
, HELP_QUIT
, 0);
215 return DefWindowProc (hwnd
, iMsg
, wParam
, lParam
);