1 |
|
---|
2 | /***********************************************************************
|
---|
3 |
|
---|
4 | $Id: presparm.c 1039 2008-07-05 22:16:21Z gyoung $
|
---|
5 |
|
---|
6 | Edit presentation parameters
|
---|
7 |
|
---|
8 | Copyright (c) 1993-98 M. Kimes
|
---|
9 | Copyright (c) 2006 Steven H.Levine
|
---|
10 |
|
---|
11 | 22 Jul 06 SHL Check more run time errors
|
---|
12 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
13 | 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus
|
---|
14 | 10 Dec 07 GKY Updated CopyPresParams to copy all parameter types
|
---|
15 | 29 Feb 08 GKY Use xfree where appropriate
|
---|
16 |
|
---|
17 | ***********************************************************************/
|
---|
18 |
|
---|
19 | #include <string.h>
|
---|
20 |
|
---|
21 | #define INCL_WIN
|
---|
22 | #define INCL_LONGLONG // dircnrs.h
|
---|
23 |
|
---|
24 | #include "fm3dll.h"
|
---|
25 | #include "fortify.h"
|
---|
26 |
|
---|
27 | // static PSZ pszSrcFile = __FILE__;
|
---|
28 |
|
---|
29 | #ifdef NEVER
|
---|
30 | /*
|
---|
31 | * this routine will fill a buffer with all defined window pres params
|
---|
32 | * the PRESPARAMS structure returned is suitable to be passed as
|
---|
33 | * pPresParams ie. WinCreateWindow(,,,,,,,,,,,, PVOID pPresParams)
|
---|
34 | */
|
---|
35 | VOID StoreWndPresParams(HWND hwnd, CHAR * tagname, HINI prof)
|
---|
36 | {
|
---|
37 | PARAM *pparam;
|
---|
38 | PRESPARAMS *ppresparams;
|
---|
39 |
|
---|
40 | if (!tagname || !*tagname || !prof)
|
---|
41 | return;
|
---|
42 | /* setup memory access */
|
---|
43 | ppresparams = (PRESPARAMS *) xmalloc(PP_MAXBUF, pszSrcFile, __LINE__);
|
---|
44 | if (!ppresparams)
|
---|
45 | return;
|
---|
46 | ppresparams->cb = 0; /* no entries yet */
|
---|
47 | pparam = ppresparams->aparam; /* cast structure onto memory */
|
---|
48 |
|
---|
49 | /*
|
---|
50 | * query every possible presentation parameter...
|
---|
51 | */
|
---|
52 |
|
---|
53 | /* foreground color -- takes 12 bytes */
|
---|
54 | pparam->cb = WinQueryPresParam(hwnd,
|
---|
55 | PP_FOREGROUNDCOLOR,
|
---|
56 | PP_FOREGROUNDCOLORINDEX,
|
---|
57 | &pparam->id,
|
---|
58 | sizeof(LONG),
|
---|
59 | (PVOID) pparam->ab, QPF_NOINHERIT);
|
---|
60 | if (pparam->cb) { /* was the param found? */
|
---|
61 | ppresparams->cb += 12; /* used 12 bytes */
|
---|
62 | pparam = (PPARAM) (((ULONG) pparam) + 12); /* advance 12 bytes to next memory location */
|
---|
63 | }
|
---|
64 |
|
---|
65 | /* background color -- takes 12 bytes */
|
---|
66 | pparam->cb = WinQueryPresParam(hwnd,
|
---|
67 | PP_BACKGROUNDCOLOR,
|
---|
68 | PP_BACKGROUNDCOLORINDEX,
|
---|
69 | &pparam->id,
|
---|
70 | sizeof(LONG),
|
---|
71 | (PVOID) pparam->ab, QPF_NOINHERIT);
|
---|
72 | if (pparam->cb) {
|
---|
73 | ppresparams->cb += 12;
|
---|
74 | pparam = (PPARAM) (((ULONG) pparam) + 12);
|
---|
75 | }
|
---|
76 |
|
---|
77 | /* hilited foreground color -- takes 12 bytes */
|
---|
78 | pparam->cb = WinQueryPresParam(hwnd,
|
---|
79 | PP_HILITEFOREGROUNDCOLOR,
|
---|
80 | PP_HILITEFOREGROUNDCOLORINDEX,
|
---|
81 | &pparam->id,
|
---|
82 | sizeof(LONG),
|
---|
83 | (PVOID) pparam->ab, QPF_NOINHERIT);
|
---|
84 | if (pparam->cb) {
|
---|
85 | ppresparams->cb += 12;
|
---|
86 | pparam = (PPARAM) (((ULONG) pparam) + 12);
|
---|
87 | }
|
---|
88 |
|
---|
89 | /* hilited background color -- takes 12 bytes */
|
---|
90 | pparam->cb = WinQueryPresParam(hwnd,
|
---|
91 | PP_HILITEBACKGROUNDCOLOR,
|
---|
92 | PP_HILITEBACKGROUNDCOLORINDEX,
|
---|
93 | &pparam->id,
|
---|
94 | sizeof(LONG),
|
---|
95 | (PVOID) pparam->ab, QPF_NOINHERIT);
|
---|
96 | if (pparam->cb) {
|
---|
97 | ppresparams->cb += 12;
|
---|
98 | pparam = (PPARAM) (((ULONG) pparam) + 12);
|
---|
99 | }
|
---|
100 |
|
---|
101 | /* disabled foreground color -- takes 12 bytes */
|
---|
102 | pparam->cb = WinQueryPresParam(hwnd,
|
---|
103 | PP_DISABLEDFOREGROUNDCOLOR,
|
---|
104 | PP_DISABLEDFOREGROUNDCOLORINDEX,
|
---|
105 | &pparam->id,
|
---|
106 | sizeof(LONG),
|
---|
107 | (PVOID) pparam->ab, QPF_NOINHERIT);
|
---|
108 | if (pparam->cb) {
|
---|
109 | ppresparams->cb += 12;
|
---|
110 | pparam = (PPARAM) (((ULONG) pparam) + 12);
|
---|
111 | }
|
---|
112 |
|
---|
113 | /* disabled background color -- takes 12 bytes */
|
---|
114 | pparam->cb = WinQueryPresParam(hwnd,
|
---|
115 | PP_DISABLEDBACKGROUNDCOLOR,
|
---|
116 | PP_DISABLEDBACKGROUNDCOLORINDEX,
|
---|
117 | &pparam->id,
|
---|
118 | sizeof(LONG),
|
---|
119 | (PVOID) pparam->ab, QPF_NOINHERIT);
|
---|
120 | if (pparam->cb) {
|
---|
121 | ppresparams->cb += 12;
|
---|
122 | pparam = (PPARAM) (((ULONG) pparam) + 12);
|
---|
123 | }
|
---|
124 |
|
---|
125 | /* border color -- takes 12 bytes */
|
---|
126 | pparam->cb = WinQueryPresParam(hwnd,
|
---|
127 | PP_BORDERCOLOR,
|
---|
128 | PP_BORDERCOLORINDEX,
|
---|
129 | &pparam->id,
|
---|
130 | sizeof(LONG),
|
---|
131 | (PVOID) pparam->ab, QPF_NOINHERIT);
|
---|
132 | if (pparam->cb) {
|
---|
133 | ppresparams->cb += 12;
|
---|
134 | pparam = (PPARAM) (((ULONG) pparam) + 12);
|
---|
135 | }
|
---|
136 |
|
---|
137 | /* font name & size -- maximum 44 bytes (32 for face name, 4 for point size) + 8 for data */
|
---|
138 | pparam->cb = WinQueryPresParam(hwnd,
|
---|
139 | PP_FONTNAMESIZE,
|
---|
140 | 0,
|
---|
141 | &pparam->id,
|
---|
142 | 36, (PVOID) pparam->ab, QPF_NOINHERIT);
|
---|
143 | if (pparam->cb) {
|
---|
144 | ppresparams->cb += (pparam->cb + 8);
|
---|
145 | pparam = (PPARAM) (((ULONG) pparam) + pparam->cb + 8);
|
---|
146 | }
|
---|
147 |
|
---|
148 | /* active color -- takes 12 bytes */
|
---|
149 | pparam->cb = WinQueryPresParam(hwnd,
|
---|
150 | PP_ACTIVECOLOR,
|
---|
151 | PP_ACTIVECOLORINDEX,
|
---|
152 | &pparam->id,
|
---|
153 | sizeof(LONG),
|
---|
154 | (PVOID) pparam->ab, QPF_NOINHERIT);
|
---|
155 | if (pparam->cb) {
|
---|
156 | ppresparams->cb += 12;
|
---|
157 | pparam = (PPARAM) (((ULONG) pparam) + 12);
|
---|
158 | }
|
---|
159 |
|
---|
160 | /* inactive color -- takes 12 bytes */
|
---|
161 | pparam->cb = WinQueryPresParam(hwnd,
|
---|
162 | PP_INACTIVECOLOR,
|
---|
163 | PP_INACTIVECOLORINDEX,
|
---|
164 | &pparam->id,
|
---|
165 | sizeof(LONG),
|
---|
166 | (PVOID) pparam->ab, QPF_NOINHERIT);
|
---|
167 | if (pparam->cb) {
|
---|
168 | ppresparams->cb += 12;
|
---|
169 | pparam = (PPARAM) (((ULONG) pparam) + 12);
|
---|
170 | }
|
---|
171 |
|
---|
172 | /* active text foreground color -- takes 12 bytes */
|
---|
173 | pparam->cb = WinQueryPresParam(hwnd,
|
---|
174 | PP_ACTIVETEXTFGNDCOLOR,
|
---|
175 | PP_ACTIVETEXTFGNDCOLORINDEX,
|
---|
176 | &pparam->id,
|
---|
177 | sizeof(LONG),
|
---|
178 | (PVOID) pparam->ab,
|
---|
179 | QPF_NOINHERIT | QPF_PURERGBCOLOR);
|
---|
180 | if (pparam->cb) {
|
---|
181 | ppresparams->cb += 12;
|
---|
182 | pparam = (PPARAM) (((ULONG) pparam) + 12);
|
---|
183 | }
|
---|
184 |
|
---|
185 | /* active text background color -- takes 12 bytes */
|
---|
186 | pparam->cb = WinQueryPresParam(hwnd,
|
---|
187 | PP_ACTIVETEXTBGNDCOLOR,
|
---|
188 | PP_ACTIVETEXTBGNDCOLORINDEX,
|
---|
189 | &pparam->id,
|
---|
190 | sizeof(LONG),
|
---|
191 | (PVOID) pparam->ab,
|
---|
192 | QPF_NOINHERIT | QPF_PURERGBCOLOR);
|
---|
193 | if (pparam->cb) {
|
---|
194 | ppresparams->cb += 12;
|
---|
195 | pparam = (PPARAM) (((ULONG) pparam) + 12);
|
---|
196 | }
|
---|
197 |
|
---|
198 | /* inactive text foreground color -- takes 12 bytes */
|
---|
199 | pparam->cb = WinQueryPresParam(hwnd,
|
---|
200 | PP_INACTIVETEXTFGNDCOLOR,
|
---|
201 | PP_INACTIVETEXTFGNDCOLORINDEX,
|
---|
202 | &pparam->id,
|
---|
203 | sizeof(LONG),
|
---|
204 | (PVOID) pparam->ab,
|
---|
205 | QPF_NOINHERIT | QPF_PURERGBCOLOR);
|
---|
206 | if (pparam->cb) {
|
---|
207 | ppresparams->cb += 12;
|
---|
208 | pparam = (PPARAM) (((ULONG) pparam) + 12);
|
---|
209 | }
|
---|
210 |
|
---|
211 | /* inactive text background color -- takes 12 bytes */
|
---|
212 | pparam->cb = WinQueryPresParam(hwnd,
|
---|
213 | PP_INACTIVETEXTBGNDCOLOR,
|
---|
214 | PP_INACTIVETEXTBGNDCOLORINDEX,
|
---|
215 | &pparam->id,
|
---|
216 | sizeof(LONG),
|
---|
217 | (PVOID) pparam->ab,
|
---|
218 | QPF_NOINHERIT | QPF_PURERGBCOLOR);
|
---|
219 | if (pparam->cb) {
|
---|
220 | ppresparams->cb += 12;
|
---|
221 | pparam = (PPARAM) (((ULONG) pparam) + 12);
|
---|
222 | }
|
---|
223 |
|
---|
224 | /* shadow color -- takes 12 bytes */
|
---|
225 | pparam->cb = WinQueryPresParam(hwnd,
|
---|
226 | PP_SHADOW, 0,
|
---|
227 | &pparam->id,
|
---|
228 | sizeof(LONG),
|
---|
229 | (PVOID) pparam->ab, QPF_NOINHERIT);
|
---|
230 | if (pparam->cb) {
|
---|
231 | ppresparams->cb += 12;
|
---|
232 | pparam = (PPARAM) (((ULONG) pparam) + 12);
|
---|
233 | }
|
---|
234 |
|
---|
235 | /* menu foreground color -- takes 12 bytes */
|
---|
236 | pparam->cb = WinQueryPresParam(hwnd,
|
---|
237 | PP_MENUFOREGROUNDCOLOR,
|
---|
238 | PP_MENUFOREGROUNDCOLORINDEX,
|
---|
239 | &pparam->id,
|
---|
240 | sizeof(LONG),
|
---|
241 | (PVOID) pparam->ab, QPF_NOINHERIT);
|
---|
242 | if (pparam->cb) {
|
---|
243 | ppresparams->cb += 12;
|
---|
244 | pparam = (PPARAM) (((ULONG) pparam) + 12);
|
---|
245 | }
|
---|
246 |
|
---|
247 | /* menu background color -- takes 12 bytes */
|
---|
248 | pparam->cb = WinQueryPresParam(hwnd,
|
---|
249 | PP_MENUBACKGROUNDCOLOR,
|
---|
250 | PP_MENUBACKGROUNDCOLORINDEX,
|
---|
251 | &pparam->id,
|
---|
252 | sizeof(LONG),
|
---|
253 | (PVOID) pparam->ab, QPF_NOINHERIT);
|
---|
254 | if (pparam->cb) {
|
---|
255 | ppresparams->cb += 12;
|
---|
256 | pparam = (PPARAM) (((ULONG) pparam) + 12);
|
---|
257 | }
|
---|
258 |
|
---|
259 | /* menu hilite foreground color -- takes 12 bytes */
|
---|
260 | pparam->cb = WinQueryPresParam(hwnd,
|
---|
261 | PP_MENUHILITEFGNDCOLOR,
|
---|
262 | PP_MENUHILITEFGNDCOLORINDEX,
|
---|
263 | &pparam->id,
|
---|
264 | sizeof(LONG),
|
---|
265 | (PVOID) pparam->ab, QPF_NOINHERIT);
|
---|
266 | if (pparam->cb) {
|
---|
267 | ppresparams->cb += 12;
|
---|
268 | pparam = (PPARAM) (((ULONG) pparam) + 12);
|
---|
269 | }
|
---|
270 |
|
---|
271 | /* menu hilite background color -- takes 12 bytes */
|
---|
272 | pparam->cb = WinQueryPresParam(hwnd,
|
---|
273 | PP_MENUHILITEBGNDCOLOR,
|
---|
274 | PP_MENUHILITEBGNDCOLORINDEX,
|
---|
275 | &pparam->id,
|
---|
276 | sizeof(LONG),
|
---|
277 | (PVOID) pparam->ab, QPF_NOINHERIT);
|
---|
278 | if (pparam->cb) {
|
---|
279 | ppresparams->cb += 12;
|
---|
280 | pparam = (PPARAM) (((ULONG) pparam) + 12);
|
---|
281 | }
|
---|
282 |
|
---|
283 | /* menu disabled foreground color -- takes 12 bytes */
|
---|
284 | pparam->cb = WinQueryPresParam(hwnd,
|
---|
285 | PP_MENUDISABLEDFGNDCOLOR,
|
---|
286 | PP_MENUDISABLEDFGNDCOLORINDEX,
|
---|
287 | &pparam->id,
|
---|
288 | sizeof(LONG),
|
---|
289 | (PVOID) pparam->ab, QPF_NOINHERIT);
|
---|
290 | if (pparam->cb) {
|
---|
291 | ppresparams->cb += 12;
|
---|
292 | pparam = (PPARAM) (((ULONG) pparam) + 12);
|
---|
293 | }
|
---|
294 |
|
---|
295 | /* menu disabled background color -- takes 12 bytes */
|
---|
296 | pparam->cb = WinQueryPresParam(hwnd,
|
---|
297 | PP_MENUDISABLEDBGNDCOLOR,
|
---|
298 | PP_MENUDISABLEDBGNDCOLORINDEX,
|
---|
299 | &pparam->id,
|
---|
300 | sizeof(LONG),
|
---|
301 | (PVOID) pparam->ab, QPF_NOINHERIT);
|
---|
302 | if (pparam->cb) {
|
---|
303 | ppresparams->cb += 12;
|
---|
304 | pparam = (PPARAM) (((ULONG) pparam) + 12);
|
---|
305 | }
|
---|
306 |
|
---|
307 | if (ppresparams->cb)
|
---|
308 | PrfWriteProfileData(prof,
|
---|
309 | appname, tagname, ppresparams, ppresparams->cb + 4);
|
---|
310 |
|
---|
311 | free(ppresparams);
|
---|
312 | }
|
---|
313 |
|
---|
314 | #endif // NEVER
|
---|
315 |
|
---|
316 | VOID CopyPresParams(HWND target, HWND source)
|
---|
317 | {
|
---|
318 | /*
|
---|
319 | * Copy presentation parameters of interest to us from one window
|
---|
320 | * to another
|
---|
321 | */
|
---|
322 |
|
---|
323 | ULONG AttrFound, AttrValue[64], cbRetLen, x = 0,
|
---|
324 | AttrName[] = { PP_FONTNAMESIZE, PP_FOREGROUNDCOLOR,
|
---|
325 | PP_BACKGROUNDCOLOR, PP_HILITEBACKGROUNDCOLOR,
|
---|
326 | PP_HILITEFOREGROUNDCOLOR, PP_BORDERCOLOR, PP_MENUFOREGROUNDCOLOR,
|
---|
327 | PP_MENUBACKGROUNDCOLOR, PP_FOREGROUNDCOLORINDEX, PP_BACKGROUNDCOLORINDEX,
|
---|
328 | PP_HILITEFOREGROUNDCOLORINDEX, PP_HILITEBACKGROUNDCOLORINDEX,
|
---|
329 | PP_DISABLEDFOREGROUNDCOLOR, PP_DISABLEDBACKGROUNDCOLOR,
|
---|
330 | PP_DISABLEDFOREGROUNDCOLORINDEX, PP_DISABLEDBACKGROUNDCOLORINDEX,
|
---|
331 | PP_BORDERCOLOR, PP_BORDERCOLORINDEX, PP_FONTHANDLE, PP_ACTIVECOLOR,
|
---|
332 | PP_ACTIVECOLORINDEX, PP_INACTIVECOLOR, PP_INACTIVECOLORINDEX,
|
---|
333 | PP_ACTIVETEXTFGNDCOLOR, PP_ACTIVETEXTFGNDCOLORINDEX, PP_ACTIVETEXTBGNDCOLOR,
|
---|
334 | PP_ACTIVETEXTBGNDCOLORINDEX, PP_INACTIVETEXTFGNDCOLOR,
|
---|
335 | PP_INACTIVETEXTFGNDCOLORINDEX, PP_INACTIVETEXTBGNDCOLOR,
|
---|
336 | PP_INACTIVETEXTBGNDCOLORINDEX, PP_SHADOW, PP_MENUFOREGROUNDCOLORINDEX,
|
---|
337 | PP_MENUBACKGROUNDCOLORINDEX, PP_MENUHILITEFGNDCOLOR, PP_MENUHILITEFGNDCOLORINDEX,
|
---|
338 | PP_MENUHILITEBGNDCOLOR, PP_MENUHILITEBGNDCOLORINDEX, PP_MENUDISABLEDFGNDCOLOR,
|
---|
339 | PP_MENUDISABLEDFGNDCOLORINDEX, PP_MENUDISABLEDBGNDCOLOR,
|
---|
340 | PP_MENUDISABLEDBGNDCOLORINDEX, PP_SHADOWTEXTCOLOR, PP_SHADOWTEXTCOLORINDEX,
|
---|
341 | PP_SHADOWHILITEFGNDCOLOR, PP_SHADOWHILITEFGNDCOLORINDEX, PP_SHADOWHILITEBGNDCOLOR,
|
---|
342 | PP_SHADOWHILITEBGNDCOLORINDEX, PP_ICONTEXTBACKGROUNDCOLOR,
|
---|
343 | PP_ICONTEXTBACKGROUNDCOLORINDEX, PP_BORDERLIGHTCOLOR, PP_BORDERDARKCOLOR,
|
---|
344 | PP_BORDER2COLOR, PP_BORDER2LIGHTCOLOR, PP_BORDER2DARKCOLOR, PP_BORDERDEFAULTCOLOR,
|
---|
345 | PP_FIELDBACKGROUNDCOLOR, PP_BUTTONBACKGROUNDCOLOR, PP_BUTTONBORDERLIGHTCOLOR,
|
---|
346 | PP_BUTTONBORDERDARKCOLOR, PP_ARROWCOLOR, PP_ARROWBORDERLIGHTCOLOR,
|
---|
347 | PP_ARROWBORDERDARKCOLOR, PP_ARROWDISABLEDCOLOR, PP_CHECKLIGHTCOLOR,
|
---|
348 | PP_CHECKMIDDLECOLOR, PP_CHECKDARKCOLOR, PP_PAGEFOREGROUNDCOLOR,
|
---|
349 | PP_PAGEBACKGROUNDCOLOR, PP_MAJORTABFOREGROUNDCOLOR, PP_MAJORTABBACKGROUNDCOLOR,
|
---|
350 | PP_MINORTABFOREGROUNDCOLOR, PP_MINORTABBACKGROUNDCOLOR, PP_USER, 0 };
|
---|
351 |
|
---|
352 | while (AttrName[x]) {
|
---|
353 | cbRetLen = WinQueryPresParam(source,
|
---|
354 | AttrName[x],
|
---|
355 | 0,
|
---|
356 | &AttrFound,
|
---|
357 | sizeof(AttrValue),
|
---|
358 | &AttrValue, 0);
|
---|
359 | //printf("%s %x\n", AttrValue, source); fflush(stdout);
|
---|
360 | //printf("%x\n", AttrValue); fflush(stdout);
|
---|
361 | if (cbRetLen)
|
---|
362 | WinSetPresParam(target, AttrName[x], cbRetLen, (PVOID) AttrValue);
|
---|
363 | x++;
|
---|
364 | } //while
|
---|
365 | }
|
---|
366 |
|
---|
367 | VOID SetPresParams(HWND hwnd, RGB2 * back, RGB2 * fore, RGB2 * border,
|
---|
368 | CHAR * font)
|
---|
369 | {
|
---|
370 | if (font)
|
---|
371 | WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(font) + 1, (PVOID) font);
|
---|
372 | if (back)
|
---|
373 | WinSetPresParam(hwnd, PP_BACKGROUNDCOLOR, sizeof(RGB2), (PVOID) back);
|
---|
374 | if (fore)
|
---|
375 | WinSetPresParam(hwnd, PP_FOREGROUNDCOLOR, sizeof(RGB2), (PVOID) fore);
|
---|
376 | if (border)
|
---|
377 | WinSetPresParam(hwnd, PP_BORDERCOLOR, sizeof(RGB2), (PVOID) border);
|
---|
378 | }
|
---|
379 |
|
---|
380 | VOID IfNoParam(HWND hwnd, CHAR * keyroot, ULONG size, PVOID attrvalue)
|
---|
381 | {
|
---|
382 | ULONG fsize = 0;
|
---|
383 | CHAR s[81];
|
---|
384 |
|
---|
385 | sprintf(s, "%s", keyroot);
|
---|
386 | if (!PrfQueryProfileSize(fmprof, appname, s, &fsize) || !fsize)
|
---|
387 | WinSetPresParam(hwnd, PP_FONTNAMESIZE, size, (PVOID) attrvalue);
|
---|
388 | }
|
---|
389 |
|
---|
390 | VOID PresParamChanged(HWND hwnd, CHAR * keyroot, MPARAM mp1, MPARAM mp2)
|
---|
391 | {
|
---|
392 | ULONG AttrFound, AttrValue[64], cbRetLen;
|
---|
393 |
|
---|
394 | cbRetLen = WinQueryPresParam(hwnd, (ULONG) mp1, 0, &AttrFound,
|
---|
395 | (ULONG) sizeof(AttrValue), &AttrValue, 0);
|
---|
396 | if (cbRetLen) {
|
---|
397 |
|
---|
398 | CHAR s[133];
|
---|
399 |
|
---|
400 | *s = 0;
|
---|
401 | switch (AttrFound) {
|
---|
402 | case PP_BACKGROUNDCOLOR:
|
---|
403 | sprintf(s, "%s.Backgroundcolor", keyroot);
|
---|
404 | break;
|
---|
405 | case PP_FOREGROUNDCOLOR:
|
---|
406 | sprintf(s, "%s.Foregroundcolor", keyroot);
|
---|
407 | break;
|
---|
408 | case PP_HILITEBACKGROUNDCOLOR:
|
---|
409 | sprintf(s, "%s.Hilitebackgroundcolor", keyroot);
|
---|
410 | break;
|
---|
411 | case PP_HILITEFOREGROUNDCOLOR:
|
---|
412 | sprintf(s, "%s.Hiliteforegroundcolor", keyroot);
|
---|
413 | break;
|
---|
414 | case PP_BORDERCOLOR:
|
---|
415 | sprintf(s, "%s.Bordercolor", keyroot);
|
---|
416 | break;
|
---|
417 | case PP_FONTNAMESIZE:
|
---|
418 | sprintf(s, "%s.Fontnamesize", keyroot);
|
---|
419 | break;
|
---|
420 | default:
|
---|
421 | break;
|
---|
422 | }
|
---|
423 | if (*s)
|
---|
424 | PrfWriteProfileData(fmprof, appname, s, (PVOID) AttrValue, cbRetLen);
|
---|
425 | }
|
---|
426 | }
|
---|
427 |
|
---|
428 | VOID RestorePresParams(HWND hwnd, CHAR * keyroot)
|
---|
429 | {
|
---|
430 | CHAR s[81];
|
---|
431 | ULONG AttrValue[64], size;
|
---|
432 |
|
---|
433 | size = sizeof(AttrValue);
|
---|
434 | sprintf(s, "%s.Backgroundcolor", keyroot);
|
---|
435 | if (PrfQueryProfileData(fmprof, appname, s, (PVOID) AttrValue, &size)
|
---|
436 | && size)
|
---|
437 | WinSetPresParam(hwnd, PP_BACKGROUNDCOLOR, size, (PVOID) AttrValue);
|
---|
438 | size = sizeof(AttrValue);
|
---|
439 | sprintf(s, "%s.Foregroundcolor", keyroot);
|
---|
440 | if (PrfQueryProfileData(fmprof, appname, s, (PVOID) AttrValue, &size)
|
---|
441 | && size)
|
---|
442 | WinSetPresParam(hwnd, PP_FOREGROUNDCOLOR, size, (PVOID) AttrValue);
|
---|
443 | size = sizeof(AttrValue);
|
---|
444 | sprintf(s, "%s.Hilitebackgroundcolor", keyroot);
|
---|
445 | if (PrfQueryProfileData(fmprof, appname, s, (PVOID) AttrValue, &size)
|
---|
446 | && size)
|
---|
447 | WinSetPresParam(hwnd, PP_HILITEBACKGROUNDCOLOR, size, (PVOID) AttrValue);
|
---|
448 | size = sizeof(AttrValue);
|
---|
449 | sprintf(s, "%s.Hiliteforegroundcolor", keyroot);
|
---|
450 | if (PrfQueryProfileData(fmprof, appname, s, (PVOID) AttrValue, &size)
|
---|
451 | && size)
|
---|
452 | WinSetPresParam(hwnd, PP_HILITEFOREGROUNDCOLOR, size, (PVOID) AttrValue);
|
---|
453 | size = sizeof(AttrValue);
|
---|
454 | sprintf(s, "%s.Bordercolor", keyroot);
|
---|
455 | if (PrfQueryProfileData(fmprof, appname, s, (PVOID) AttrValue, &size)
|
---|
456 | && size)
|
---|
457 | WinSetPresParam(hwnd, PP_BORDERCOLOR, size, (PVOID) AttrValue);
|
---|
458 | size = sizeof(AttrValue);
|
---|
459 | sprintf(s, "%s.Fontnamesize", keyroot);
|
---|
460 | if (PrfQueryProfileData(fmprof,
|
---|
461 | appname, s, (PVOID) AttrValue, &size) && size)
|
---|
462 | WinSetPresParam(hwnd, PP_FONTNAMESIZE, size, (PVOID) AttrValue);
|
---|
463 | }
|
---|
464 |
|
---|
465 | /** SavePresParams
|
---|
466 | * Save the presentation parameters used by RestorePresParams
|
---|
467 | */
|
---|
468 | VOID SavePresParams(HWND hwnd, CHAR *keyroot)
|
---|
469 | {
|
---|
470 |
|
---|
471 |
|
---|
472 | ULONG AttrFound, AttrValue[64], cbRetLen, x = 0,
|
---|
473 | AttrName[] = { PP_FONTNAMESIZE, PP_FOREGROUNDCOLOR,
|
---|
474 | PP_BACKGROUNDCOLOR, PP_HILITEBACKGROUNDCOLOR,
|
---|
475 | PP_HILITEFOREGROUNDCOLOR, PP_BORDERCOLOR, 0 };
|
---|
476 |
|
---|
477 | while (AttrName[x]) {
|
---|
478 | cbRetLen = WinQueryPresParam(hwnd,
|
---|
479 | AttrName[x],
|
---|
480 | 0,
|
---|
481 | &AttrFound,
|
---|
482 | sizeof(AttrValue),
|
---|
483 | &AttrValue, 0);
|
---|
484 | if (cbRetLen){
|
---|
485 | CHAR s[133];
|
---|
486 |
|
---|
487 | *s = 0;
|
---|
488 | switch (AttrFound) {
|
---|
489 | case PP_BACKGROUNDCOLOR:
|
---|
490 | sprintf(s, "%s.Backgroundcolor", keyroot);
|
---|
491 | break;
|
---|
492 | case PP_FOREGROUNDCOLOR:
|
---|
493 | sprintf(s, "%s.Foregroundcolor", keyroot);
|
---|
494 | break;
|
---|
495 | case PP_HILITEBACKGROUNDCOLOR:
|
---|
496 | sprintf(s, "%s.Hilitebackgroundcolor", keyroot);
|
---|
497 | break;
|
---|
498 | case PP_HILITEFOREGROUNDCOLOR:
|
---|
499 | sprintf(s, "%s.Hiliteforegroundcolor", keyroot);
|
---|
500 | break;
|
---|
501 | case PP_BORDERCOLOR:
|
---|
502 | sprintf(s, "%s.Bordercolor", keyroot);
|
---|
503 | break;
|
---|
504 | case PP_FONTNAMESIZE:
|
---|
505 | sprintf(s, "%s.Fontnamesize", keyroot);
|
---|
506 | break;
|
---|
507 | default:
|
---|
508 | break;
|
---|
509 | }
|
---|
510 | if (*s)
|
---|
511 | PrfWriteProfileData(fmprof, appname, s, (PVOID) AttrValue, cbRetLen);
|
---|
512 | }
|
---|
513 | x++;
|
---|
514 | } //while
|
---|
515 | }
|
---|
516 |
|
---|
517 | #pragma alloc_text(PRESPARAM,CopyPresParams,SetPresParams,IfNoParam)
|
---|
518 | #pragma alloc_text(PRESPARAM,PresParamChanged,RestorePresParams,SavePresParams)
|
---|
519 | #pragma alloc_text(PRESPARAM,StoreWndPresParams)
|
---|