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
);
31 int main ( int argc
, char** argv
)
33 return WinMain ( NULL
, NULL
, NULL
, SW_SHOW
);
39 int WINAPI
WinMain (HINSTANCE hInst
, HINSTANCE hPrev
, PSTR szCmdLine
, int iCmdShow
)
44 INITCOMMONCONTROLSEX ice
;
49 //Window class for the main application parent window
50 wndclass
.cbSize
= sizeof(wndclass
);
51 wndclass
.style
= 0;//CS_HREDRAW | CS_VREDRAW;
52 wndclass
.lpfnWndProc
= WndProc
;
53 wndclass
.cbClsExtra
= 0;
54 wndclass
.cbWndExtra
= 0;
55 wndclass
.hInstance
= hInst
;
56 wndclass
.hIcon
= LoadIcon (hInst
, MAKEINTRESOURCE(IDI_ICON1
));
57 wndclass
.hCursor
= LoadCursor (NULL
, IDC_ARROW
);
58 wndclass
.hbrBackground
= (HBRUSH
)NULL
;
59 wndclass
.lpszMenuName
= MAKEINTRESOURCE(IDR_MENU1
);
60 wndclass
.lpszClassName
= szAppName
;
61 wndclass
.hIconSm
= (HICON
)LoadImage(hInst
, MAKEINTRESOURCE(IDI_ICON1
), IMAGE_ICON
, 16, 16, 0);
63 RegisterClassEx(&wndclass
);
65 ice
.dwSize
= sizeof(ice
);
66 ice
.dwICC
= ICC_BAR_CLASSES
;
67 InitCommonControlsEx(&ice
);
69 srand((unsigned)GetTickCount());//timeGetTime());
75 //Construct the path to our help file
76 MakePath(szHelpPath
, MAX_PATH
, _T(".hlp"));
78 hwnd
= CreateWindow(szAppName
, // window class name
79 szAppName
, // window caption
81 ,//|WS_CLIPCHILDREN, // window style
82 CW_USEDEFAULT
, // initial x position
83 CW_USEDEFAULT
, // initial y position
84 CW_USEDEFAULT
, // initial x size
85 CW_USEDEFAULT
, // initial y size
86 NULL
, // parent window handle
87 NULL
, // use window class menu
88 hInst
, // program instance handle
89 NULL
); // creation parameters
93 ShowWindow(hwnd
, iCmdShow
);
96 hAccelTable
= LoadAccelerators(hInstance
, MAKEINTRESOURCE(IDR_ACCELERATOR1
));
98 while(GetMessage(&msg
, NULL
,0,0))
100 if(!TranslateAccelerator(hwnd
, hAccelTable
, &msg
))
102 TranslateMessage(&msg
);
103 DispatchMessage(&msg
);
113 //-----------------------------------------------------------------------------
114 LRESULT CALLBACK
WndProc (HWND hwnd
, UINT iMsg
, WPARAM wParam
, LPARAM lParam
)
116 static int nWidth
, nHeight
;
117 int nStatusHeight
= 0;//20;
118 int parts
[] = { 100, -1 };
126 hwndStatus
= CreateStatusWindow(WS_CHILD
| WS_VISIBLE
| CCS_BOTTOM
| SBARS_SIZEGRIP
, "Ready", hwnd
, 0);
128 //SendMessage(hwndStatus, SB_SIMPLE, (WPARAM)TRUE, 0);
130 SendMessage(hwndStatus
, SB_SETPARTS
, 2, (LPARAM
)parts
);
131 SendMessage(hwndStatus
, SB_SETTEXT
, 0 | SBT_NOBORDERS
, (LPARAM
)"");
133 ShowWindow(hwndStatus
, SW_HIDE
);
135 SolWnd
.Create(hwnd
, WS_EX_CLIENTEDGE
, WS_CHILD
|WS_VISIBLE
, 0, 0, 0, 0);
141 dwAppStartTime
= GetTickCount();
150 nWidth
= LOWORD(lParam
);
151 nHeight
= HIWORD(lParam
);
153 MoveWindow(SolWnd
, 0, 0, nWidth
, nHeight
-nStatusHeight
, TRUE
);
154 //MoveWindow(hwndStatus, 0, nHeight-nStatusHeight, nWidth, nHeight, TRUE);
155 //parts[0] = nWidth - 256;
156 //SendMessage(hwndStatus, SB_SETPARTS, 2, (LPARAM)parts);
160 case WM_GETMINMAXINFO
:
161 mmi
= (MINMAXINFO
*)lParam
;
162 mmi
->ptMinTrackSize
.x
= 600;
163 mmi
->ptMinTrackSize
.y
= 400;
169 switch(LOWORD(wParam
))
172 //simulate a button click on the new button..
177 //ShowDeckOptionsDlg(hwnd);
180 case IDM_GAME_OPTIONS
:
181 //ShowGameOptionsDlg(hwnd);
184 case IDM_HELP_CONTENTS
:
186 WinHelp(hwnd
, szHelpPath
, HELP_CONTENTS
, 0);//HELP_KEY, (DWORD)"How to play");
191 MessageBox(hwnd
, _T("Solitare by J Brown\r\n\r\nCardLib version 1.0."), szAppName
, MB_OK
|MB_ICONINFORMATION
);
196 PostMessage(hwnd
, WM_CLOSE
, 0, 0);
208 ret
= MessageBox(hwnd
, _T("Quit the current game?"), szAppName
, MB_OKCANCEL
|MB_ICONQUESTION
);
213 WinHelp(hwnd
, szHelpPath
, HELP_QUIT
, 0);
220 return DefWindowProc (hwnd
, iMsg
, wParam
, lParam
);