-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDLGPROC.C
275 lines (243 loc) · 8.33 KB
/
DLGPROC.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
/*
**************************************************************************
dlgproc.c Brett A. Morrison
This file contains several call back routines for processing dialog boxes.
**************************************************************************
*/
#include "golf.h"
extern char szAppName[];
extern char szUntitled[];
extern char szc_name[];
extern char szmm[];
extern char szdd[];
extern char szyy[];
extern char szCsearch_for[];
extern char szNDTitle[];
extern char szPsearch_for[];
extern BOOL bYesNo;
extern BOOL bDeleteRounds;
extern BOOL bNameDate;
extern WORD wWhich;
extern int iPkey;
extern int iCkey;
/*
--------------------------------------------------------------------------
DoCaption
Sets the caption of the window by getting szAppName, which is defined
globally, and appending the current filename to it.
Inputs:
hwnd - The handle of the main window
szFileNameP - The current filename of the player file in memory
szFileNameC - The current filename of the course file in memory
Outputs:
None
--------------------------------------------------------------------------
*/
void DoCaption(HWND hwnd, char *szFileTitleP, char *szFileTitleC)
{ /* DoCaption */
char szCaption[MAX_CAPTION]; /* String to hold caption */
/* Set the buffer for the caption, and determine if a file is in memory,
if not, append szAppName with szUntitled */
wsprintf(szCaption, "%s - %s %s", (LPSTR)szAppName,
(LPSTR)(szFileTitleC[NULL] ? szFileTitleC : szUntitled),
(LPSTR)(szFileTitleP[NULL] ? szFileTitleP : szUntitled));
SetWindowText(hwnd, szCaption); /* Display caption */
} /* DoCaption */
/*
--------------------------------------------------------------------------
AskAboutSave
Asks user to save changes.
Inputs:
hwnd - The handle of the main window
szFileName - The current filename of the file in memory
which - checks if the file is a course or player file
Outputs:
TRUE if user selects YES
FALSE if user cancels box
--------------------------------------------------------------------------
*/
short AskAboutSave(HWND hwnd, char *szFileTitle, char which)
{ /* AskAboutSave */
char szBuffer[FILE_NAME_SIZE]; /* holds filename and path */
short nReturn; /* stores boolean output */
/* Set the buffer for the dialog box, with a prompt and filename */
wsprintf(szBuffer, "Save current changes: %s",
(LPSTR)(szFileTitle[NULL] ? szFileTitle : szUntitled));
/* then send a save message */
if (IDYES == (nReturn = MessageBox(hwnd, szBuffer, szAppName,
MB_YESNOCANCEL | MB_ICONQUESTION)))
switch(which)
{
case PLAYER_MARKER:
if (!SendMessage(hwnd, WM_COMMAND, IDM_SAVE_P, 0L)) /* then message failed */
return IDCANCEL;
break;
case COURSE_MARKER:
if (!SendMessage(hwnd, WM_COMMAND, IDM_SAVE_C, 0L)) /* then message failed */
return IDCANCEL;
break;
} /* switch */
return nReturn;
} /* AskAboutSave */
/*
--------------------------------------------------------------------------
AboutDlgProc
Displays about complete golf handicapper dialog box.
Inputs:
hDlg - Handle to parent window
message - Message sent from MainWndProc
wParam - Command from MainWndProc
Outputs:
TRUE, so the calling program can close the dialog box
FALSE if control is switched to another window
--------------------------------------------------------------------------
*/
BOOL FAR PASCAL AboutDlgProc(HWND hDlg, WORD message, WORD wParam, LONG lParam)
{
switch(message) /* checks message */
{ /* switch(message) */
case WM_INITDIALOG: /* checks if box has already been loaded in memory */
return TRUE;
case WM_COMMAND:
switch(wParam) /* checks command */
{ /* switch(wParam) */
case IDOK: /* do nothing and fall through */
case IDCANCEL: /* IDOK is same as cancel, so close box */
EndDialog(hDlg, NULL);
return TRUE; /* End procedure */
} /* switch(wParam) */
break;
} /* switch(message) */
return FALSE; /* Control has been switched to another window */
} /* AboutDlgProc */
BOOL FAR PASCAL DeleteCourseDlgProc(HWND hDlg, WORD message, WORD wParam,
LONG lParam)
{
switch(message)
{
case WM_INITDIALOG:
SetDlgItemText(hDlg, IDD_DC_CNAME, szc_name);
SendMessage(GetDlgItem(hDlg, IDD_DC_ROUNDS), BM_SETCHECK, 1, 0L);
return TRUE;
case WM_COMMAND:
switch (wParam)
{
case IDYES:
bYesNo = IDYES;
bDeleteRounds =
(BOOL)SendMessage(GetDlgItem(hDlg, IDD_DC_ROUNDS), BM_GETCHECK, 0, 0L);
EndDialog(hDlg, TRUE);
return TRUE;
case IDNO:
case IDCANCEL:
bYesNo = IDNO;
EndDialog(hDlg, FALSE);
return TRUE;
} /* switch (wParam) */
break;
} /* switch(wParam) */
return FALSE;
} /* DeleteCourseDlgProc */
BOOL FAR PASCAL NameDateDlgProc(HWND hDlg, WORD message, WORD wParam, LONG lParam)
{
switch(message)
{
case WM_INITDIALOG:
SetDlgItemText(hDlg, IDD_ND_CNAME, szc_name);
SetDlgItemText(hDlg, IDD_ND_MM, szmm);
SetDlgItemText(hDlg, IDD_ND_DD, szdd);
SetDlgItemText(hDlg, IDD_ND_YY, szyy);
SetWindowText(hDlg, szNDTitle);
return TRUE;
case WM_COMMAND:
switch (wParam)
{
case IDOK:
bNameDate = IDOK;
GetDlgItemText(hDlg, IDD_ND_CNAME, szc_name, COURSE_NAME_LENGTH+1);
GetDlgItemText(hDlg, IDD_ND_MM, szmm, 3);
GetDlgItemText(hDlg, IDD_ND_DD, szdd, 3);
GetDlgItemText(hDlg, IDD_ND_YY, szyy, 3);
if (!GoodDate(atoi(szmm), atoi(szdd), (atoi(szyy) + 1900)))
{
MessageBeep(0);
MessageBox(hDlg, "Invalid Date", szAppName, MB_OK | MB_ICONSTOP);
return FALSE;
}
add0(szmm);
add0(szdd);
add0(szyy);
EndDialog(hDlg, TRUE);
return TRUE;
case IDCANCEL:
bNameDate = IDCANCEL;
EndDialog(hDlg, FALSE);
return TRUE;
} /* switch (wParam) */
break;
} /* switch(message); */
return FALSE;
} /* NameDateDlgProc */
BOOL FAR PASCAL SearchDlgProc(HWND hDlg, WORD message, WORD wParam, LONG lParam)
{
static WORD wPrev;
switch(message) /* checks message */
{
case WM_INITDIALOG: /* checks if box has already been loaded in memory */
if (wWhich == IDM_P_SEARCH) /* player search */
{
SetWindowText(hDlg, "Search Player");
EnableWindow(GetDlgItem(hDlg, IDD_S_FIRSTNAME), TRUE);
EnableWindow(GetDlgItem(hDlg, IDD_S_LASTNAME), TRUE);
EnableWindow(GetDlgItem(hDlg, IDD_S_COURSE), FALSE);
SendMessage(GetDlgItem(hDlg, iPkey), BM_SETCHECK, 1, 0L);
wPrev = iPkey;
SetDlgItemText(hDlg, IDD_S_SEARCHFOR, szPsearch_for);
}
else
{
SetWindowText(hDlg, "Search Course");
EnableWindow(GetDlgItem(hDlg, IDD_S_FIRSTNAME), FALSE);
EnableWindow(GetDlgItem(hDlg, IDD_S_LASTNAME), FALSE);
EnableWindow(GetDlgItem(hDlg, IDD_S_COURSE), TRUE);
SendMessage(GetDlgItem(hDlg, iCkey), BM_SETCHECK, 1, 0L);
wPrev = iCkey;
SetDlgItemText(hDlg, IDD_S_SEARCHFOR, szCsearch_for);
}
SendMessage(GetDlgItem(hDlg, IDD_S_CURRENT), BM_SETCHECK, 1, 0L);
return TRUE;
case WM_COMMAND:
switch(wParam) /* checks command */
{
case IDD_S_FIRSTNAME:
case IDD_S_LASTNAME:
case IDD_S_COURSE:
case IDD_S_STREET:
case IDD_S_CITY:
case IDD_S_STATE:
case IDD_S_ZIP:
case IDD_S_PHONE:
((wWhich == IDM_P_SEARCH) ? (iPkey = (int)wParam) : (iCkey = (int)wParam));
SendMessage(GetDlgItem(hDlg, wPrev), BM_SETCHECK, 0, 0L);
SendMessage(GetDlgItem(hDlg, wParam), BM_SETCHECK, 1, 0L);
wPrev = wParam;
return NULL;
case IDOK:
(wWhich == IDM_P_SEARCH) ?
GetDlgItemText(hDlg, IDD_S_SEARCHFOR, szPsearch_for, SEARCH_LENGTH+1) :
GetDlgItemText(hDlg, IDD_S_SEARCHFOR, szCsearch_for, SEARCH_LENGTH+1);
EndDialog(hDlg, TRUE);
(wWhich == IDM_P_SEARCH) ?
SearchFor(GetParent(hDlg), (BOOL)wWhich, iPkey, szPsearch_for,
(BOOL)SendMessage(GetDlgItem(hDlg, IDD_S_BEGINNING), BM_GETCHECK, 0, 0L)) :
SearchFor(GetParent(hDlg), (BOOL)wWhich, iCkey, szCsearch_for,
(BOOL)SendMessage(GetDlgItem(hDlg, IDD_S_BEGINNING), BM_GETCHECK, 0, 0L));
return TRUE;
case IDCANCEL: /* IDOK is same as cancel, so close box */
EndDialog(hDlg, FALSE);
return TRUE; /* End procedure */
} /* switch(wParam) */
break;
} /* switch(message) */
return FALSE; /* Control has been switched to another window */
} /* SearchDlgProc */