-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUTILS.C
147 lines (121 loc) · 4.08 KB
/
UTILS.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
#include "golf.h"
/*
**************************************************************************
utils.c Brett A. Morrison
Contains some utility helper functions
**************************************************************************
*/
extern char szAppName []; /* located in golf.c */
/*
--------------------------------------------------------------------------
OkMessageBox
This procedure simply displays a ok message box with the current filename.
It is used for replacing existing files and upon exiting.
Inputs:
hwnd - The handle to the parent window
*szString - A pointer to the message to be displayed
*szFileName - A pointer to the current file name
Outputs:
None
--------------------------------------------------------------------------
*/
void OkMessageBox(HWND hwnd, char *szString, char *szFileName)
{
char szBuffer[FULL_PATH_SIZE]; /* Stores message */
/* Set buffer */
wsprintf(szBuffer, szString, (LPSTR)szFileName);
/* Display message */
MessageBox(hwnd, szBuffer, szAppName, MB_OK | MB_ICONEXCLAMATION);
} /* OkMessageBox */
/*
--------------------------------------------------------------------------
lstrchr
Function to parse a filename string, which searches forward for the next
proper ansi value.
Inputs:
str - string to look at
ch - character to search for
Outputs
lstrchr - modified string
--------------------------------------------------------------------------
*/
LPSTR lstrchr(LPSTR str, char ch)
{
while (*str)
{
if (ch == *str) /* end of string */
return str;
str = AnsiNext(str); /* load next character */
} /* while */
return NULL;
} /* lstrchr */
/*
--------------------------------------------------------------------------
lstrrchr
Function to parse a filename string, which searches backward for the next
proper ansi value.
Inputs:
str - string to look at
ch - character to search for
Outputs
lstrrchr - modified string
--------------------------------------------------------------------------
*/
LPSTR lstrrchr(LPSTR str, char ch)
{
LPSTR strl = str + lstrlen(str); /* Add length of str to end of str */
do
{
if (ch == *strl) /* end of string */
return strl;
strl = AnsiPrev(str, strl); /* load previous character */
} /* do */
while(strl > str);
return NULL;
} /* lstrchr */
void DoMenu(WORD wParam, player_array *players, course_array *courses, int p_index,
HWND hWndRList)
{
LONG lSelect; /* Stores value of highlighted text */
WORD wEnable; /* Enables grayed menu items */
if (GetFocus() == hWndRList)
EnableMenuItem(wParam, IDM_UNDO, MF_GRAYED);
else
EnableMenuItem(wParam, IDM_UNDO,
SendMessage(GetFocus(), EM_CANUNDO, 0, 0L) ? MF_ENABLED : MF_GRAYED);
EnableMenuItem(wParam, IDM_PASTE,
IsClipboardFormatAvailable(CF_TEXT) ? MF_ENABLED : MF_GRAYED);
/* check if text is selected */
lSelect = SendMessage(GetFocus(), EM_GETSEL, 0, 0L);
if (HIWORD(lSelect) == LOWORD(lSelect))
wEnable = MF_GRAYED;
else
wEnable = MF_ENABLED;
EnableMenuItem(wParam, IDM_CUT, wEnable);
EnableMenuItem(wParam, IDM_COPY, wEnable);
EnableMenuItem(wParam, IDM_CLEAR, wEnable);
if ((*players).player_numb == -1)
wEnable = MF_GRAYED;
else
wEnable = MF_ENABLED;
EnableMenuItem(wParam, IDM_P_SEARCH, wEnable);
EnableMenuItem(wParam, IDM_P_SORT, wEnable);
EnableMenuItem(wParam, IDM_R_ADD, wEnable);
EnableMenuItem(wParam, IDM_PRINT_P, wEnable);
EnableMenuItem(wParam, IDM_P_DELETE, wEnable);
EnableMenuItem(wParam, IDM_GRAPH, wEnable);
if ((*courses).course_numb == -1)
wEnable = MF_GRAYED;
else
wEnable = MF_ENABLED;
EnableMenuItem(wParam, IDM_C_SEARCH, wEnable);
EnableMenuItem(wParam, IDM_C_SORT, wEnable);
EnableMenuItem(wParam, IDM_PRINT_C, wEnable);
EnableMenuItem(wParam, IDM_C_DELETE, wEnable);
if (((*players).player_numb == -1) || ((*players).player[p_index].p_scores.round_numb == -1))
wEnable = MF_GRAYED;
else
wEnable = MF_ENABLED;
EnableMenuItem(wParam, IDM_R_DELETE, wEnable);
EnableMenuItem(wParam, IDM_R_SORT, wEnable);
} /* DoMenu */