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