dinput: Clear action mapping with SetDataFormat().
[wine.git] / dlls / uxtheme / msstyles.c
blobed22d92325007fd0ae68bc15b0e1f7b138c9a43e
1 /*
2 * Win32 5.1 msstyles theme format
4 * Copyright (C) 2003 Kevin Koltzau
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
22 #include <stdlib.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "wingdi.h"
27 #include "winuser.h"
28 #include "winnls.h"
29 #include "vfwmsgs.h"
30 #include "uxtheme.h"
31 #include "tmschema.h"
33 #include "msstyles.h"
35 #include "wine/debug.h"
36 #include "wine/heap.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(uxtheme);
40 /***********************************************************************
41 * Defines and global variables
44 static BOOL MSSTYLES_GetNextInteger(LPCWSTR lpStringStart, LPCWSTR lpStringEnd, LPCWSTR *lpValEnd, int *value);
45 static BOOL MSSTYLES_GetNextToken(LPCWSTR lpStringStart, LPCWSTR lpStringEnd, LPCWSTR *lpValEnd, LPWSTR lpBuff, DWORD buffSize);
46 static void MSSTYLES_ParseThemeIni(PTHEME_FILE tf, BOOL setMetrics);
47 static HRESULT MSSTYLES_GetFont (LPCWSTR lpStringStart, LPCWSTR lpStringEnd, LPCWSTR *lpValEnd, LOGFONTW* logfont);
49 #define MSSTYLES_VERSION 0x0003
51 static PTHEME_FILE tfActiveTheme;
53 /***********************************************************************/
55 /**********************************************************************
56 * MSSTYLES_OpenThemeFile
58 * Load and validate a theme
60 * PARAMS
61 * lpThemeFile Path to theme file to load
62 * pszColorName Color name wanted, can be NULL
63 * pszSizeName Size name wanted, can be NULL
65 * NOTES
66 * If pszColorName or pszSizeName are NULL, the default color/size will be used.
67 * If one/both are provided, they are validated against valid color/sizes and if
68 * a match is not found, the function fails.
70 HRESULT MSSTYLES_OpenThemeFile(LPCWSTR lpThemeFile, LPCWSTR pszColorName, LPCWSTR pszSizeName, PTHEME_FILE *tf)
72 HMODULE hTheme;
73 HRSRC hrsc;
74 HRESULT hr = S_OK;
76 WORD version;
77 DWORD versize;
78 LPWSTR pszColors;
79 LPWSTR pszSelectedColor = NULL;
80 LPWSTR pszSizes;
81 LPWSTR pszSelectedSize = NULL;
82 LPWSTR tmp;
84 TRACE("Opening %s\n", debugstr_w(lpThemeFile));
86 hTheme = LoadLibraryExW(lpThemeFile, NULL, LOAD_LIBRARY_AS_DATAFILE);
88 /* Validate that this is really a theme */
89 if(!hTheme) {
90 hr = HRESULT_FROM_WIN32(GetLastError());
91 goto invalid_theme;
93 if(!(hrsc = FindResourceW(hTheme, MAKEINTRESOURCEW(1), L"PACKTHEM_VERSION"))) {
94 TRACE("No version resource found\n");
95 hr = HRESULT_FROM_WIN32(ERROR_BAD_FORMAT);
96 goto invalid_theme;
98 if((versize = SizeofResource(hTheme, hrsc)) != 2)
100 TRACE("Version resource found, but wrong size: %d\n", versize);
101 hr = HRESULT_FROM_WIN32(ERROR_BAD_FORMAT);
102 goto invalid_theme;
104 version = *(WORD*)LoadResource(hTheme, hrsc);
105 if(version != MSSTYLES_VERSION)
107 TRACE("Version of theme file is unsupported: 0x%04x\n", version);
108 hr = HRESULT_FROM_WIN32(ERROR_BAD_FORMAT);
109 goto invalid_theme;
112 if(!(hrsc = FindResourceW(hTheme, MAKEINTRESOURCEW(1), L"COLORNAMES"))) {
113 TRACE("Color names resource not found\n");
114 hr = HRESULT_FROM_WIN32(ERROR_BAD_FORMAT);
115 goto invalid_theme;
117 pszColors = LoadResource(hTheme, hrsc);
119 if(!(hrsc = FindResourceW(hTheme, MAKEINTRESOURCEW(1), L"SIZENAMES"))) {
120 TRACE("Size names resource not found\n");
121 hr = HRESULT_FROM_WIN32(ERROR_BAD_FORMAT);
122 goto invalid_theme;
124 pszSizes = LoadResource(hTheme, hrsc);
126 /* Validate requested color against what's available from the theme */
127 if(pszColorName) {
128 tmp = pszColors;
129 while(*tmp) {
130 if(!lstrcmpiW(pszColorName, tmp)) {
131 pszSelectedColor = tmp;
132 break;
134 tmp += lstrlenW(tmp)+1;
137 else
138 pszSelectedColor = pszColors; /* Use the default color */
140 /* Validate requested size against what's available from the theme */
141 if(pszSizeName) {
142 tmp = pszSizes;
143 while(*tmp) {
144 if(!lstrcmpiW(pszSizeName, tmp)) {
145 pszSelectedSize = tmp;
146 break;
148 tmp += lstrlenW(tmp)+1;
151 else
152 pszSelectedSize = pszSizes; /* Use the default size */
154 if(!pszSelectedColor || !pszSelectedSize) {
155 TRACE("Requested color/size (%s/%s) not found in theme\n",
156 debugstr_w(pszColorName), debugstr_w(pszSizeName));
157 hr = E_PROP_ID_UNSUPPORTED;
158 goto invalid_theme;
161 *tf = heap_alloc_zero(sizeof(THEME_FILE));
162 (*tf)->hTheme = hTheme;
164 GetFullPathNameW(lpThemeFile, MAX_PATH, (*tf)->szThemeFile, NULL);
166 (*tf)->pszAvailColors = pszColors;
167 (*tf)->pszAvailSizes = pszSizes;
168 (*tf)->pszSelectedColor = pszSelectedColor;
169 (*tf)->pszSelectedSize = pszSelectedSize;
170 (*tf)->dwRefCount = 1;
171 return S_OK;
173 invalid_theme:
174 *tf = NULL;
175 if(hTheme) FreeLibrary(hTheme);
176 return hr;
179 /***********************************************************************
180 * MSSTYLES_CloseThemeFile
182 * Close theme file and free resources
184 void MSSTYLES_CloseThemeFile(PTHEME_FILE tf)
186 if(tf) {
187 tf->dwRefCount--;
188 if(!tf->dwRefCount) {
189 if(tf->hTheme) FreeLibrary(tf->hTheme);
190 if(tf->classes) {
191 while(tf->classes) {
192 PTHEME_CLASS pcls = tf->classes;
193 tf->classes = pcls->next;
194 while(pcls->partstate) {
195 PTHEME_PARTSTATE ps = pcls->partstate;
197 while(ps->properties) {
198 PTHEME_PROPERTY prop = ps->properties;
199 ps->properties = prop->next;
200 heap_free(prop);
203 pcls->partstate = ps->next;
204 heap_free(ps);
206 heap_free(pcls);
209 while (tf->images)
211 PTHEME_IMAGE img = tf->images;
212 tf->images = img->next;
213 DeleteObject (img->image);
214 heap_free(img);
216 heap_free(tf);
221 /***********************************************************************
222 * MSSTYLES_SetActiveTheme
224 * Set the current active theme
226 HRESULT MSSTYLES_SetActiveTheme(PTHEME_FILE tf, BOOL setMetrics)
228 if(tfActiveTheme)
229 MSSTYLES_CloseThemeFile(tfActiveTheme);
230 tfActiveTheme = tf;
231 if (tfActiveTheme)
233 tfActiveTheme->dwRefCount++;
234 if(!tfActiveTheme->classes)
235 MSSTYLES_ParseThemeIni(tfActiveTheme, setMetrics);
237 return S_OK;
240 /***********************************************************************
241 * MSSTYLES_GetThemeIni
243 * Retrieves themes.ini from a theme
245 PUXINI_FILE MSSTYLES_GetThemeIni(PTHEME_FILE tf)
247 return UXINI_LoadINI(tf->hTheme, L"themes_ini");
250 /***********************************************************************
251 * MSSTYLES_GetActiveThemeIni
253 * Retrieve the ini file for the selected color/style
255 static PUXINI_FILE MSSTYLES_GetActiveThemeIni(PTHEME_FILE tf)
257 DWORD dwColorCount = 0;
258 DWORD dwSizeCount = 0;
259 DWORD dwColorNum = 0;
260 DWORD dwSizeNum = 0;
261 DWORD i;
262 DWORD dwResourceIndex;
263 LPWSTR tmp;
264 HRSRC hrsc;
266 /* Count the number of available colors & styles, and determine the index number
267 of the color/style we are interested in
269 tmp = tf->pszAvailColors;
270 while(*tmp) {
271 if(!lstrcmpiW(tf->pszSelectedColor, tmp))
272 dwColorNum = dwColorCount;
273 tmp += lstrlenW(tmp)+1;
274 dwColorCount++;
276 tmp = tf->pszAvailSizes;
277 while(*tmp) {
278 if(!lstrcmpiW(tf->pszSelectedSize, tmp))
279 dwSizeNum = dwSizeCount;
280 tmp += lstrlenW(tmp)+1;
281 dwSizeCount++;
284 if(!(hrsc = FindResourceW(tf->hTheme, MAKEINTRESOURCEW(1), L"FILERESNAMES"))) {
285 TRACE("FILERESNAMES map not found\n");
286 return NULL;
288 tmp = LoadResource(tf->hTheme, hrsc);
289 dwResourceIndex = (dwSizeCount * dwColorNum) + dwSizeNum;
290 for(i=0; i < dwResourceIndex; i++) {
291 tmp += lstrlenW(tmp)+1;
293 return UXINI_LoadINI(tf->hTheme, tmp);
297 /***********************************************************************
298 * MSSTYLES_ParseIniSectionName
300 * Parse an ini section name into its component parts
301 * Valid formats are:
302 * [classname]
303 * [classname(state)]
304 * [classname.part]
305 * [classname.part(state)]
306 * [application::classname]
307 * [application::classname(state)]
308 * [application::classname.part]
309 * [application::classname.part(state)]
311 * PARAMS
312 * lpSection Section name
313 * dwLen Length of section name
314 * szAppName Location to store application name
315 * szClassName Location to store class name
316 * iPartId Location to store part id
317 * iStateId Location to store state id
319 static BOOL MSSTYLES_ParseIniSectionName(LPCWSTR lpSection, DWORD dwLen, LPWSTR szAppName, LPWSTR szClassName, int *iPartId, int *iStateId)
321 WCHAR sec[255];
322 WCHAR part[60] = {'\0'};
323 WCHAR state[60] = {'\0'};
324 LPWSTR tmp;
325 LPWSTR comp;
326 lstrcpynW(sec, lpSection, min(dwLen+1, ARRAY_SIZE(sec)));
328 *szAppName = 0;
329 *szClassName = 0;
330 *iPartId = 0;
331 *iStateId = 0;
332 comp = sec;
333 /* Get the application name */
334 tmp = wcschr(comp, ':');
335 if(tmp) {
336 *tmp++ = 0;
337 tmp++;
338 lstrcpynW(szAppName, comp, MAX_THEME_APP_NAME);
339 comp = tmp;
342 tmp = wcschr(comp, '.');
343 if(tmp) {
344 *tmp++ = 0;
345 lstrcpynW(szClassName, comp, MAX_THEME_CLASS_NAME);
346 comp = tmp;
347 /* now get the part & state */
348 tmp = wcschr(comp, '(');
349 if(tmp) {
350 *tmp++ = 0;
351 lstrcpynW(part, comp, ARRAY_SIZE(part));
352 comp = tmp;
353 /* now get the state */
354 tmp = wcschr(comp, ')');
355 if (!tmp)
356 return FALSE;
357 *tmp = 0;
358 lstrcpynW(state, comp, ARRAY_SIZE(state));
360 else {
361 lstrcpynW(part, comp, ARRAY_SIZE(part));
364 else {
365 tmp = wcschr(comp, '(');
366 if(tmp) {
367 *tmp++ = 0;
368 lstrcpynW(szClassName, comp, MAX_THEME_CLASS_NAME);
369 comp = tmp;
370 /* now get the state */
371 tmp = wcschr(comp, ')');
372 if (!tmp)
373 return FALSE;
374 *tmp = 0;
375 lstrcpynW(state, comp, ARRAY_SIZE(state));
377 else {
378 lstrcpynW(szClassName, comp, MAX_THEME_CLASS_NAME);
381 if(!*szClassName) return FALSE;
382 return MSSTYLES_LookupPartState(szClassName, part[0]?part:NULL, state[0]?state:NULL, iPartId, iStateId);
385 /***********************************************************************
386 * MSSTYLES_FindClass
388 * Find a class
390 * PARAMS
391 * tf Theme file
392 * pszAppName App name to find
393 * pszClassName Class name to find
395 * RETURNS
396 * The class found, or NULL
398 static PTHEME_CLASS MSSTYLES_FindClass(PTHEME_FILE tf, LPCWSTR pszAppName, LPCWSTR pszClassName)
400 PTHEME_CLASS cur = tf->classes;
401 while(cur) {
402 if(!pszAppName) {
403 if(!*cur->szAppName && !lstrcmpiW(pszClassName, cur->szClassName))
404 return cur;
406 else {
407 if(!lstrcmpiW(pszAppName, cur->szAppName) && !lstrcmpiW(pszClassName, cur->szClassName))
408 return cur;
410 cur = cur->next;
412 return NULL;
415 /***********************************************************************
416 * MSSTYLES_AddClass
418 * Add a class to a theme file
420 * PARAMS
421 * tf Theme file
422 * pszAppName App name to add
423 * pszClassName Class name to add
425 * RETURNS
426 * The class added, or a class previously added with the same name
428 static PTHEME_CLASS MSSTYLES_AddClass(PTHEME_FILE tf, LPCWSTR pszAppName, LPCWSTR pszClassName)
430 PTHEME_CLASS cur = MSSTYLES_FindClass(tf, pszAppName, pszClassName);
431 if(cur) return cur;
433 cur = heap_alloc(sizeof(*cur));
434 cur->hTheme = tf->hTheme;
435 lstrcpyW(cur->szAppName, pszAppName);
436 lstrcpyW(cur->szClassName, pszClassName);
437 cur->next = tf->classes;
438 cur->partstate = NULL;
439 cur->overrides = NULL;
440 tf->classes = cur;
441 return cur;
444 /***********************************************************************
445 * MSSTYLES_FindPartState
447 * Find a part/state
449 * PARAMS
450 * tc Class to search
451 * iPartId Part ID to find
452 * iStateId State ID to find
453 * tcNext Receives the next class in the override chain
455 * RETURNS
456 * The part/state found, or NULL
458 PTHEME_PARTSTATE MSSTYLES_FindPartState(PTHEME_CLASS tc, int iPartId, int iStateId, PTHEME_CLASS *tcNext)
460 PTHEME_PARTSTATE cur = tc->partstate;
461 while(cur) {
462 if(cur->iPartId == iPartId && cur->iStateId == iStateId) {
463 if(tcNext) *tcNext = tc->overrides;
464 return cur;
466 cur = cur->next;
468 if(tc->overrides) return MSSTYLES_FindPartState(tc->overrides, iPartId, iStateId, tcNext);
469 return NULL;
472 /***********************************************************************
473 * MSSTYLES_AddPartState
475 * Add a part/state to a class
477 * PARAMS
478 * tc Theme class
479 * iPartId Part ID to add
480 * iStateId State ID to add
482 * RETURNS
483 * The part/state added, or a part/state previously added with the same IDs
485 static PTHEME_PARTSTATE MSSTYLES_AddPartState(PTHEME_CLASS tc, int iPartId, int iStateId)
487 PTHEME_PARTSTATE cur = MSSTYLES_FindPartState(tc, iPartId, iStateId, NULL);
488 if(cur) return cur;
490 cur = heap_alloc(sizeof(*cur));
491 cur->iPartId = iPartId;
492 cur->iStateId = iStateId;
493 cur->properties = NULL;
494 cur->next = tc->partstate;
495 tc->partstate = cur;
496 return cur;
499 /***********************************************************************
500 * MSSTYLES_LFindProperty
502 * Find a property within a property list
504 * PARAMS
505 * tp property list to scan
506 * iPropertyPrimitive Type of value expected
507 * iPropertyId ID of the required value
509 * RETURNS
510 * The property found, or NULL
512 static PTHEME_PROPERTY MSSTYLES_LFindProperty(PTHEME_PROPERTY tp, int iPropertyPrimitive, int iPropertyId)
514 PTHEME_PROPERTY cur = tp;
515 while(cur) {
516 if(cur->iPropertyId == iPropertyId) {
517 if(cur->iPrimitiveType == iPropertyPrimitive) {
518 return cur;
520 else {
521 if(!iPropertyPrimitive)
522 return cur;
523 return NULL;
526 cur = cur->next;
528 return NULL;
531 /***********************************************************************
532 * MSSTYLES_PSFindProperty
534 * Find a value within a part/state
536 * PARAMS
537 * ps Part/state to search
538 * iPropertyPrimitive Type of value expected
539 * iPropertyId ID of the required value
541 * RETURNS
542 * The property found, or NULL
544 static inline PTHEME_PROPERTY MSSTYLES_PSFindProperty(PTHEME_PARTSTATE ps, int iPropertyPrimitive, int iPropertyId)
546 return MSSTYLES_LFindProperty(ps->properties, iPropertyPrimitive, iPropertyId);
549 /***********************************************************************
550 * MSSTYLES_FFindMetric
552 * Find a metric property for a theme file
554 * PARAMS
555 * tf Theme file
556 * iPropertyPrimitive Type of value expected
557 * iPropertyId ID of the required value
559 * RETURNS
560 * The property found, or NULL
562 static inline PTHEME_PROPERTY MSSTYLES_FFindMetric(PTHEME_FILE tf, int iPropertyPrimitive, int iPropertyId)
564 return MSSTYLES_LFindProperty(tf->metrics, iPropertyPrimitive, iPropertyId);
567 /***********************************************************************
568 * MSSTYLES_FindMetric
570 * Find a metric property for the current installed theme
572 * PARAMS
573 * tf Theme file
574 * iPropertyPrimitive Type of value expected
575 * iPropertyId ID of the required value
577 * RETURNS
578 * The property found, or NULL
580 PTHEME_PROPERTY MSSTYLES_FindMetric(int iPropertyPrimitive, int iPropertyId)
582 if(!tfActiveTheme) return NULL;
583 return MSSTYLES_FFindMetric(tfActiveTheme, iPropertyPrimitive, iPropertyId);
586 /***********************************************************************
587 * MSSTYLES_AddProperty
589 * Add a property to a part/state
591 * PARAMS
592 * ps Part/state
593 * iPropertyPrimitive Primitive type of the property
594 * iPropertyId ID of the property
595 * lpValue Raw value (non-NULL terminated)
596 * dwValueLen Length of the value
598 * RETURNS
599 * The property added, or a property previously added with the same IDs
601 static PTHEME_PROPERTY MSSTYLES_AddProperty(PTHEME_PARTSTATE ps, int iPropertyPrimitive, int iPropertyId, LPCWSTR lpValue, DWORD dwValueLen, BOOL isGlobal)
603 PTHEME_PROPERTY cur = MSSTYLES_PSFindProperty(ps, iPropertyPrimitive, iPropertyId);
604 /* Should duplicate properties overwrite the original, or be ignored? */
605 if(cur) return cur;
607 cur = heap_alloc(sizeof(*cur));
608 cur->iPrimitiveType = iPropertyPrimitive;
609 cur->iPropertyId = iPropertyId;
610 cur->lpValue = lpValue;
611 cur->dwValueLen = dwValueLen;
613 if(ps->iStateId)
614 cur->origin = PO_STATE;
615 else if(ps->iPartId)
616 cur->origin = PO_PART;
617 else if(isGlobal)
618 cur->origin = PO_GLOBAL;
619 else
620 cur->origin = PO_CLASS;
622 cur->next = ps->properties;
623 ps->properties = cur;
624 return cur;
627 /***********************************************************************
628 * MSSTYLES_AddMetric
630 * Add a property to a part/state
632 * PARAMS
633 * tf Theme file
634 * iPropertyPrimitive Primitive type of the property
635 * iPropertyId ID of the property
636 * lpValue Raw value (non-NULL terminated)
637 * dwValueLen Length of the value
639 * RETURNS
640 * The property added, or a property previously added with the same IDs
642 static PTHEME_PROPERTY MSSTYLES_AddMetric(PTHEME_FILE tf, int iPropertyPrimitive, int iPropertyId, LPCWSTR lpValue, DWORD dwValueLen)
644 PTHEME_PROPERTY cur = MSSTYLES_FFindMetric(tf, iPropertyPrimitive, iPropertyId);
645 /* Should duplicate properties overwrite the original, or be ignored? */
646 if(cur) return cur;
648 cur = heap_alloc(sizeof(*cur));
649 cur->iPrimitiveType = iPropertyPrimitive;
650 cur->iPropertyId = iPropertyId;
651 cur->lpValue = lpValue;
652 cur->dwValueLen = dwValueLen;
654 cur->origin = PO_GLOBAL;
656 cur->next = tf->metrics;
657 tf->metrics = cur;
658 return cur;
661 /* Color-related state for theme ini parsing */
662 struct PARSECOLORSTATE
664 int colorCount;
665 int colorElements[TMT_LASTCOLOR-TMT_FIRSTCOLOR+1];
666 COLORREF colorRgb[TMT_LASTCOLOR-TMT_FIRSTCOLOR+1];
667 int captionColors;
670 static inline void parse_init_color (struct PARSECOLORSTATE* state)
672 memset (state, 0, sizeof (*state));
675 static BOOL parse_handle_color_property (struct PARSECOLORSTATE* state,
676 int iPropertyId, LPCWSTR lpValue,
677 DWORD dwValueLen)
679 int r,g,b;
680 LPCWSTR lpValueEnd = lpValue + dwValueLen;
681 if(MSSTYLES_GetNextInteger(lpValue, lpValueEnd, &lpValue, &r) &&
682 MSSTYLES_GetNextInteger(lpValue, lpValueEnd, &lpValue, &g) &&
683 MSSTYLES_GetNextInteger(lpValue, lpValueEnd, &lpValue, &b)) {
684 state->colorElements[state->colorCount] = iPropertyId - TMT_FIRSTCOLOR;
685 state->colorRgb[state->colorCount++] = RGB(r,g,b);
686 switch (iPropertyId)
688 case TMT_ACTIVECAPTION:
689 state->captionColors |= 0x1;
690 break;
691 case TMT_INACTIVECAPTION:
692 state->captionColors |= 0x2;
693 break;
694 case TMT_GRADIENTACTIVECAPTION:
695 state->captionColors |= 0x4;
696 break;
697 case TMT_GRADIENTINACTIVECAPTION:
698 state->captionColors |= 0x8;
699 break;
701 return TRUE;
703 else {
704 return FALSE;
708 static void parse_apply_color (struct PARSECOLORSTATE* state)
710 if (state->colorCount > 0)
711 SetSysColors(state->colorCount, state->colorElements, state->colorRgb);
712 if (state->captionColors == 0xf)
713 SystemParametersInfoW (SPI_SETGRADIENTCAPTIONS, 0, (PVOID)TRUE, 0);
716 /* Non-client-metrics-related state for theme ini parsing */
717 struct PARSENONCLIENTSTATE
719 NONCLIENTMETRICSW metrics;
720 BOOL metricsDirty;
721 LOGFONTW iconTitleFont;
724 static inline void parse_init_nonclient (struct PARSENONCLIENTSTATE* state)
726 memset (state, 0, sizeof (*state));
727 state->metrics.cbSize = sizeof (NONCLIENTMETRICSW);
728 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, sizeof (NONCLIENTMETRICSW),
729 &state->metrics, 0);
730 SystemParametersInfoW (SPI_GETICONTITLELOGFONT, sizeof (LOGFONTW),
731 &state->iconTitleFont, 0);
734 static BOOL parse_handle_nonclient_font (struct PARSENONCLIENTSTATE* state,
735 int iPropertyId, LPCWSTR lpValue,
736 DWORD dwValueLen)
738 LOGFONTW font;
740 memset (&font, 0, sizeof (font));
741 if (SUCCEEDED (MSSTYLES_GetFont (lpValue, lpValue + dwValueLen, &lpValue,
742 &font)))
744 switch (iPropertyId)
746 case TMT_CAPTIONFONT:
747 state->metrics.lfCaptionFont = font;
748 state->metricsDirty = TRUE;
749 break;
750 case TMT_SMALLCAPTIONFONT:
751 state->metrics.lfSmCaptionFont = font;
752 state->metricsDirty = TRUE;
753 break;
754 case TMT_MENUFONT:
755 state->metrics.lfMenuFont = font;
756 state->metricsDirty = TRUE;
757 break;
758 case TMT_STATUSFONT:
759 state->metrics.lfStatusFont = font;
760 state->metricsDirty = TRUE;
761 break;
762 case TMT_MSGBOXFONT:
763 state->metrics.lfMessageFont = font;
764 state->metricsDirty = TRUE;
765 break;
766 case TMT_ICONTITLEFONT:
767 state->iconTitleFont = font;
768 state->metricsDirty = TRUE;
769 break;
771 return TRUE;
773 else
774 return FALSE;
777 static BOOL parse_handle_nonclient_size (struct PARSENONCLIENTSTATE* state,
778 int iPropertyId, LPCWSTR lpValue,
779 DWORD dwValueLen)
781 int size;
782 LPCWSTR lpValueEnd = lpValue + dwValueLen;
783 if(MSSTYLES_GetNextInteger(lpValue, lpValueEnd, &lpValue, &size)) {
784 switch (iPropertyId)
786 case TMT_SIZINGBORDERWIDTH:
787 state->metrics.iBorderWidth = size;
788 state->metricsDirty = TRUE;
789 break;
790 case TMT_SCROLLBARWIDTH:
791 state->metrics.iScrollWidth = size;
792 state->metricsDirty = TRUE;
793 break;
794 case TMT_SCROLLBARHEIGHT:
795 state->metrics.iScrollHeight = size;
796 state->metricsDirty = TRUE;
797 break;
798 case TMT_CAPTIONBARWIDTH:
799 state->metrics.iCaptionWidth = size;
800 state->metricsDirty = TRUE;
801 break;
802 case TMT_CAPTIONBARHEIGHT:
803 state->metrics.iCaptionHeight = size;
804 state->metricsDirty = TRUE;
805 break;
806 case TMT_SMCAPTIONBARWIDTH:
807 state->metrics.iSmCaptionWidth = size;
808 state->metricsDirty = TRUE;
809 break;
810 case TMT_SMCAPTIONBARHEIGHT:
811 state->metrics.iSmCaptionHeight = size;
812 state->metricsDirty = TRUE;
813 break;
814 case TMT_MENUBARWIDTH:
815 state->metrics.iMenuWidth = size;
816 state->metricsDirty = TRUE;
817 break;
818 case TMT_MENUBARHEIGHT:
819 state->metrics.iMenuHeight = size;
820 state->metricsDirty = TRUE;
821 break;
823 return TRUE;
825 else
826 return FALSE;
829 static void parse_apply_nonclient (struct PARSENONCLIENTSTATE* state)
831 if (state->metricsDirty)
833 SystemParametersInfoW (SPI_SETNONCLIENTMETRICS, sizeof (state->metrics),
834 &state->metrics, 0);
835 SystemParametersInfoW (SPI_SETICONTITLELOGFONT, sizeof (state->iconTitleFont),
836 &state->iconTitleFont, 0);
840 /***********************************************************************
841 * MSSTYLES_ParseThemeIni
843 * Parse the theme ini for the selected color/style
845 * PARAMS
846 * tf Theme to parse
848 static void MSSTYLES_ParseThemeIni(PTHEME_FILE tf, BOOL setMetrics)
850 PTHEME_CLASS cls;
851 PTHEME_CLASS globals;
852 PTHEME_PARTSTATE ps;
853 PUXINI_FILE ini;
854 WCHAR szAppName[MAX_THEME_APP_NAME];
855 WCHAR szClassName[MAX_THEME_CLASS_NAME];
856 WCHAR szPropertyName[MAX_THEME_VALUE_NAME];
857 int iPartId;
858 int iStateId;
859 int iPropertyPrimitive;
860 int iPropertyId;
861 DWORD dwLen;
862 LPCWSTR lpName;
863 DWORD dwValueLen;
864 LPCWSTR lpValue;
866 ini = MSSTYLES_GetActiveThemeIni(tf);
868 while((lpName=UXINI_GetNextSection(ini, &dwLen))) {
869 if(CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE, lpName, dwLen, L"SysMetrics", -1) == CSTR_EQUAL) {
870 struct PARSECOLORSTATE colorState;
871 struct PARSENONCLIENTSTATE nonClientState;
873 parse_init_color (&colorState);
874 parse_init_nonclient (&nonClientState);
876 while((lpName=UXINI_GetNextValue(ini, &dwLen, &lpValue, &dwValueLen))) {
877 lstrcpynW(szPropertyName, lpName, min(dwLen+1, ARRAY_SIZE(szPropertyName)));
878 if(MSSTYLES_LookupProperty(szPropertyName, &iPropertyPrimitive, &iPropertyId)) {
879 if(iPropertyId >= TMT_FIRSTCOLOR && iPropertyId <= TMT_LASTCOLOR) {
880 if (!parse_handle_color_property (&colorState, iPropertyId,
881 lpValue, dwValueLen))
882 FIXME("Invalid color value for %s\n",
883 debugstr_w(szPropertyName));
885 else if (setMetrics && (iPropertyId == TMT_FLATMENUS)) {
886 BOOL flatMenus = (*lpValue == 'T') || (*lpValue == 't');
887 SystemParametersInfoW (SPI_SETFLATMENU, 0, (PVOID)(INT_PTR)flatMenus, 0);
889 else if ((iPropertyId >= TMT_FIRSTFONT)
890 && (iPropertyId <= TMT_LASTFONT))
892 if (!parse_handle_nonclient_font (&nonClientState,
893 iPropertyId, lpValue, dwValueLen))
894 FIXME("Invalid font value for %s\n",
895 debugstr_w(szPropertyName));
897 else if ((iPropertyId >= TMT_FIRSTSIZE)
898 && (iPropertyId <= TMT_LASTSIZE))
900 if (!parse_handle_nonclient_size (&nonClientState,
901 iPropertyId, lpValue, dwValueLen))
902 FIXME("Invalid size value for %s\n",
903 debugstr_w(szPropertyName));
905 /* Catch all metrics, including colors */
906 MSSTYLES_AddMetric(tf, iPropertyPrimitive, iPropertyId, lpValue, dwValueLen);
908 else {
909 TRACE("Unknown system metric %s\n", debugstr_w(szPropertyName));
912 if (setMetrics)
914 parse_apply_color (&colorState);
915 parse_apply_nonclient (&nonClientState);
917 continue;
919 if(MSSTYLES_ParseIniSectionName(lpName, dwLen, szAppName, szClassName, &iPartId, &iStateId)) {
920 BOOL isGlobal = FALSE;
921 if(!lstrcmpiW(szClassName, L"globals")) {
922 isGlobal = TRUE;
924 cls = MSSTYLES_AddClass(tf, szAppName, szClassName);
925 ps = MSSTYLES_AddPartState(cls, iPartId, iStateId);
927 while((lpName=UXINI_GetNextValue(ini, &dwLen, &lpValue, &dwValueLen))) {
928 lstrcpynW(szPropertyName, lpName, min(dwLen+1, ARRAY_SIZE(szPropertyName)));
929 if(MSSTYLES_LookupProperty(szPropertyName, &iPropertyPrimitive, &iPropertyId)) {
930 MSSTYLES_AddProperty(ps, iPropertyPrimitive, iPropertyId, lpValue, dwValueLen, isGlobal);
932 else {
933 TRACE("Unknown property %s\n", debugstr_w(szPropertyName));
939 /* App/Class combos override values defined by the base class, map these overrides */
940 globals = MSSTYLES_FindClass(tf, NULL, L"globals");
941 cls = tf->classes;
942 while(cls) {
943 if(*cls->szAppName) {
944 cls->overrides = MSSTYLES_FindClass(tf, NULL, cls->szClassName);
945 if(!cls->overrides) {
946 TRACE("No overrides found for app %s class %s\n", debugstr_w(cls->szAppName), debugstr_w(cls->szClassName));
948 else {
949 cls->overrides = globals;
952 else {
953 /* Everything overrides globals..except globals */
954 if(cls != globals) cls->overrides = globals;
956 cls = cls->next;
958 UXINI_CloseINI(ini);
960 if(!tf->classes) {
961 ERR("Failed to parse theme ini\n");
965 /***********************************************************************
966 * MSSTYLES_OpenThemeClass
968 * Open a theme class, uses the current active theme
970 * PARAMS
971 * pszAppName Application name, for theme styles specific
972 * to a particular application
973 * pszClassList List of requested classes, semicolon delimited
975 PTHEME_CLASS MSSTYLES_OpenThemeClass(LPCWSTR pszAppName, LPCWSTR pszClassList)
977 PTHEME_CLASS cls = NULL;
978 WCHAR szClassName[MAX_THEME_CLASS_NAME];
979 LPCWSTR start;
980 LPCWSTR end;
981 DWORD len;
983 if(!tfActiveTheme) {
984 TRACE("there is no active theme\n");
985 return NULL;
987 if(!tfActiveTheme->classes) {
988 return NULL;
991 start = pszClassList;
992 while((end = wcschr(start, ';'))) {
993 len = end-start;
994 lstrcpynW(szClassName, start, min(len+1, ARRAY_SIZE(szClassName)));
995 start = end+1;
996 cls = MSSTYLES_FindClass(tfActiveTheme, pszAppName, szClassName);
997 if(cls) break;
999 if(!cls && *start) {
1000 lstrcpynW(szClassName, start, ARRAY_SIZE(szClassName));
1001 cls = MSSTYLES_FindClass(tfActiveTheme, pszAppName, szClassName);
1003 if(cls) {
1004 TRACE("Opened app %s, class %s from list %s\n", debugstr_w(cls->szAppName), debugstr_w(cls->szClassName), debugstr_w(pszClassList));
1005 cls->tf = tfActiveTheme;
1006 cls->tf->dwRefCount++;
1008 return cls;
1011 /***********************************************************************
1012 * MSSTYLES_CloseThemeClass
1014 * Close a theme class
1016 * PARAMS
1017 * tc Theme class to close
1019 * NOTES
1020 * The MSSTYLES_CloseThemeFile decreases the refcount of the owning
1021 * theme file and cleans it up, if needed.
1023 HRESULT MSSTYLES_CloseThemeClass(PTHEME_CLASS tc)
1025 MSSTYLES_CloseThemeFile (tc->tf);
1026 return S_OK;
1029 /***********************************************************************
1030 * MSSTYLES_FindProperty
1032 * Locate a property in a class. Part and state IDs will be used as a
1033 * preference, but may be ignored in the attempt to locate the property.
1034 * Will scan the entire chain of overrides for this class.
1036 PTHEME_PROPERTY MSSTYLES_FindProperty(PTHEME_CLASS tc, int iPartId, int iStateId, int iPropertyPrimitive, int iPropertyId)
1038 PTHEME_CLASS next = tc;
1039 PTHEME_PARTSTATE ps;
1040 PTHEME_PROPERTY tp;
1042 TRACE("(%p, %d, %d, %d)\n", tc, iPartId, iStateId, iPropertyId);
1043 /* Try and find an exact match on part & state */
1044 while(next && (ps = MSSTYLES_FindPartState(next, iPartId, iStateId, &next))) {
1045 if((tp = MSSTYLES_PSFindProperty(ps, iPropertyPrimitive, iPropertyId))) {
1046 return tp;
1049 /* If that fails, and we didn't already try it, search for just part */
1050 if(iStateId != 0)
1051 iStateId = 0;
1052 /* As a last ditch attempt..go for just class */
1053 else if(iPartId != 0)
1054 iPartId = 0;
1055 else
1056 return NULL;
1058 if((tp = MSSTYLES_FindProperty(tc, iPartId, iStateId, iPropertyPrimitive, iPropertyId)))
1059 return tp;
1060 return NULL;
1063 /* Prepare a bitmap to be used for alpha blending */
1064 static BOOL prepare_alpha (HBITMAP bmp, BOOL* hasAlpha)
1066 DIBSECTION dib;
1067 int n;
1068 BYTE* p;
1070 *hasAlpha = FALSE;
1072 if (!bmp || GetObjectW( bmp, sizeof(dib), &dib ) != sizeof(dib))
1073 return FALSE;
1075 if(dib.dsBm.bmBitsPixel != 32)
1076 /* nothing to do */
1077 return TRUE;
1079 *hasAlpha = TRUE;
1080 p = dib.dsBm.bmBits;
1081 n = dib.dsBmih.biHeight * dib.dsBmih.biWidth;
1082 /* AlphaBlend() wants premultiplied alpha, so do that now */
1083 while (n-- > 0)
1085 int a = p[3]+1;
1086 p[0] = (p[0] * a) >> 8;
1087 p[1] = (p[1] * a) >> 8;
1088 p[2] = (p[2] * a) >> 8;
1089 p += 4;
1092 return TRUE;
1095 HBITMAP MSSTYLES_LoadBitmap (PTHEME_CLASS tc, LPCWSTR lpFilename, BOOL* hasAlpha)
1097 WCHAR szFile[MAX_PATH];
1098 LPWSTR tmp;
1099 PTHEME_IMAGE img;
1100 lstrcpynW(szFile, lpFilename, ARRAY_SIZE(szFile));
1101 tmp = szFile;
1102 do {
1103 if(*tmp == '\\') *tmp = '_';
1104 if(*tmp == '/') *tmp = '_';
1105 if(*tmp == '.') *tmp = '_';
1106 } while(*tmp++);
1108 /* Try to locate in list of loaded images */
1109 img = tc->tf->images;
1110 while (img)
1112 if (lstrcmpiW (szFile, img->name) == 0)
1114 TRACE ("found %p %s: %p\n", img, debugstr_w (img->name), img->image);
1115 *hasAlpha = img->hasAlpha;
1116 return img->image;
1118 img = img->next;
1120 /* Not found? Load from resources */
1121 img = heap_alloc(sizeof(*img));
1122 img->image = LoadImageW(tc->hTheme, szFile, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
1123 prepare_alpha (img->image, hasAlpha);
1124 img->hasAlpha = *hasAlpha;
1125 /* ...and stow away for later reuse. */
1126 lstrcpyW (img->name, szFile);
1127 img->next = tc->tf->images;
1128 tc->tf->images = img;
1129 TRACE ("new %p %s: %p\n", img, debugstr_w (img->name), img->image);
1130 return img->image;
1133 static BOOL MSSTYLES_GetNextInteger(LPCWSTR lpStringStart, LPCWSTR lpStringEnd, LPCWSTR *lpValEnd, int *value)
1135 LPCWSTR cur = lpStringStart;
1136 int total = 0;
1137 BOOL gotNeg = FALSE;
1139 while(cur < lpStringEnd && (*cur < '0' || *cur > '9' || *cur == '-')) cur++;
1140 if(cur >= lpStringEnd) {
1141 return FALSE;
1143 if(*cur == '-') {
1144 cur++;
1145 gotNeg = TRUE;
1147 while(cur < lpStringEnd && (*cur >= '0' && *cur <= '9')) {
1148 total = total * 10 + (*cur - '0');
1149 cur++;
1151 if(gotNeg) total = -total;
1152 *value = total;
1153 if(lpValEnd) *lpValEnd = cur;
1154 return TRUE;
1157 static inline BOOL isSpace(WCHAR c)
1159 return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v';
1162 static BOOL MSSTYLES_GetNextToken(LPCWSTR lpStringStart, LPCWSTR lpStringEnd, LPCWSTR *lpValEnd, LPWSTR lpBuff, DWORD buffSize) {
1163 LPCWSTR cur = lpStringStart;
1164 LPCWSTR start;
1165 LPCWSTR end;
1167 while(cur < lpStringEnd && (isSpace(*cur) || *cur == ',')) cur++;
1168 if(cur >= lpStringEnd) {
1169 return FALSE;
1171 start = cur;
1172 while(cur < lpStringEnd && *cur != ',') cur++;
1173 end = cur;
1174 while(isSpace(*end)) end--;
1176 lstrcpynW(lpBuff, start, min(buffSize, end-start+1));
1178 if(lpValEnd) *lpValEnd = cur;
1179 return TRUE;
1182 /***********************************************************************
1183 * MSSTYLES_GetPropertyBool
1185 * Retrieve a color value for a property
1187 HRESULT MSSTYLES_GetPropertyBool(PTHEME_PROPERTY tp, BOOL *pfVal)
1189 *pfVal = FALSE;
1190 if(*tp->lpValue == 't' || *tp->lpValue == 'T')
1191 *pfVal = TRUE;
1192 return S_OK;
1195 /***********************************************************************
1196 * MSSTYLES_GetPropertyColor
1198 * Retrieve a color value for a property
1200 HRESULT MSSTYLES_GetPropertyColor(PTHEME_PROPERTY tp, COLORREF *pColor)
1202 LPCWSTR lpEnd;
1203 LPCWSTR lpCur;
1204 int red, green, blue;
1206 lpCur = tp->lpValue;
1207 lpEnd = tp->lpValue + tp->dwValueLen;
1209 if(!MSSTYLES_GetNextInteger(lpCur, lpEnd, &lpCur, &red)) {
1210 TRACE("Could not parse color property\n");
1211 return E_PROP_ID_UNSUPPORTED;
1213 if(!MSSTYLES_GetNextInteger(lpCur, lpEnd, &lpCur, &green)) {
1214 TRACE("Could not parse color property\n");
1215 return E_PROP_ID_UNSUPPORTED;
1217 if(!MSSTYLES_GetNextInteger(lpCur, lpEnd, &lpCur, &blue)) {
1218 TRACE("Could not parse color property\n");
1219 return E_PROP_ID_UNSUPPORTED;
1221 *pColor = RGB(red,green,blue);
1222 return S_OK;
1225 /***********************************************************************
1226 * MSSTYLES_GetPropertyColor
1228 * Retrieve a color value for a property
1230 static HRESULT MSSTYLES_GetFont (LPCWSTR lpCur, LPCWSTR lpEnd,
1231 LPCWSTR *lpValEnd, LOGFONTW* pFont)
1233 int pointSize;
1234 WCHAR attr[32];
1236 if(!MSSTYLES_GetNextToken(lpCur, lpEnd, &lpCur, pFont->lfFaceName, LF_FACESIZE)) {
1237 TRACE("Property is there, but failed to get face name\n");
1238 *lpValEnd = lpCur;
1239 return E_PROP_ID_UNSUPPORTED;
1241 if(!MSSTYLES_GetNextInteger(lpCur, lpEnd, &lpCur, &pointSize)) {
1242 TRACE("Property is there, but failed to get point size\n");
1243 *lpValEnd = lpCur;
1244 return E_PROP_ID_UNSUPPORTED;
1246 pFont->lfHeight = pointSize;
1247 pFont->lfWeight = FW_REGULAR;
1248 pFont->lfCharSet = DEFAULT_CHARSET;
1249 while(MSSTYLES_GetNextToken(lpCur, lpEnd, &lpCur, attr, ARRAY_SIZE(attr))) {
1250 if(!lstrcmpiW(L"bold", attr)) pFont->lfWeight = FW_BOLD;
1251 else if(!lstrcmpiW(L"italic", attr)) pFont->lfItalic = TRUE;
1252 else if(!lstrcmpiW(L"underline", attr)) pFont->lfUnderline = TRUE;
1253 else if(!lstrcmpiW(L"strikeout", attr)) pFont->lfStrikeOut = TRUE;
1255 *lpValEnd = lpCur;
1256 return S_OK;
1259 HRESULT MSSTYLES_GetPropertyFont(PTHEME_PROPERTY tp, HDC hdc, LOGFONTW *pFont)
1261 LPCWSTR lpCur = tp->lpValue;
1262 LPCWSTR lpEnd = tp->lpValue + tp->dwValueLen;
1263 HRESULT hr;
1265 ZeroMemory(pFont, sizeof(LOGFONTW));
1266 hr = MSSTYLES_GetFont (lpCur, lpEnd, &lpCur, pFont);
1267 if (SUCCEEDED (hr))
1268 pFont->lfHeight = -MulDiv(pFont->lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72);
1270 return hr;
1273 /***********************************************************************
1274 * MSSTYLES_GetPropertyInt
1276 * Retrieve an int value for a property
1278 HRESULT MSSTYLES_GetPropertyInt(PTHEME_PROPERTY tp, int *piVal)
1280 if(!MSSTYLES_GetNextInteger(tp->lpValue, (tp->lpValue + tp->dwValueLen), NULL, piVal)) {
1281 TRACE("Could not parse int property\n");
1282 return E_PROP_ID_UNSUPPORTED;
1284 return S_OK;
1287 /***********************************************************************
1288 * MSSTYLES_GetPropertyIntList
1290 * Retrieve an int list value for a property
1292 HRESULT MSSTYLES_GetPropertyIntList(PTHEME_PROPERTY tp, INTLIST *pIntList)
1294 int i;
1295 LPCWSTR lpCur = tp->lpValue;
1296 LPCWSTR lpEnd = tp->lpValue + tp->dwValueLen;
1298 for(i=0; i < MAX_INTLIST_COUNT; i++) {
1299 if(!MSSTYLES_GetNextInteger(lpCur, lpEnd, &lpCur, &pIntList->iValues[i]))
1300 break;
1302 pIntList->iValueCount = i;
1303 return S_OK;
1306 /***********************************************************************
1307 * MSSTYLES_GetPropertyPosition
1309 * Retrieve a position value for a property
1311 HRESULT MSSTYLES_GetPropertyPosition(PTHEME_PROPERTY tp, POINT *pPoint)
1313 int x,y;
1314 LPCWSTR lpCur = tp->lpValue;
1315 LPCWSTR lpEnd = tp->lpValue + tp->dwValueLen;
1317 if(!MSSTYLES_GetNextInteger(lpCur, lpEnd, &lpCur, &x)) {
1318 TRACE("Could not parse position property\n");
1319 return E_PROP_ID_UNSUPPORTED;
1321 if(!MSSTYLES_GetNextInteger(lpCur, lpEnd, &lpCur, &y)) {
1322 TRACE("Could not parse position property\n");
1323 return E_PROP_ID_UNSUPPORTED;
1325 pPoint->x = x;
1326 pPoint->y = y;
1327 return S_OK;
1330 /***********************************************************************
1331 * MSSTYLES_GetPropertyString
1333 * Retrieve a string value for a property
1335 HRESULT MSSTYLES_GetPropertyString(PTHEME_PROPERTY tp, LPWSTR pszBuff, int cchMaxBuffChars)
1337 lstrcpynW(pszBuff, tp->lpValue, min(tp->dwValueLen+1, cchMaxBuffChars));
1338 return S_OK;
1341 /***********************************************************************
1342 * MSSTYLES_GetPropertyRect
1344 * Retrieve a rect value for a property
1346 HRESULT MSSTYLES_GetPropertyRect(PTHEME_PROPERTY tp, RECT *pRect)
1348 LPCWSTR lpCur = tp->lpValue;
1349 LPCWSTR lpEnd = tp->lpValue + tp->dwValueLen;
1351 MSSTYLES_GetNextInteger(lpCur, lpEnd, &lpCur, &pRect->left);
1352 MSSTYLES_GetNextInteger(lpCur, lpEnd, &lpCur, &pRect->top);
1353 MSSTYLES_GetNextInteger(lpCur, lpEnd, &lpCur, &pRect->right);
1354 if(!MSSTYLES_GetNextInteger(lpCur, lpEnd, &lpCur, &pRect->bottom)) {
1355 TRACE("Could not parse rect property\n");
1356 return E_PROP_ID_UNSUPPORTED;
1358 return S_OK;
1361 /***********************************************************************
1362 * MSSTYLES_GetPropertyMargins
1364 * Retrieve a margins value for a property
1366 HRESULT MSSTYLES_GetPropertyMargins(PTHEME_PROPERTY tp, RECT *prc, MARGINS *pMargins)
1368 LPCWSTR lpCur = tp->lpValue;
1369 LPCWSTR lpEnd = tp->lpValue + tp->dwValueLen;
1371 MSSTYLES_GetNextInteger(lpCur, lpEnd, &lpCur, &pMargins->cxLeftWidth);
1372 MSSTYLES_GetNextInteger(lpCur, lpEnd, &lpCur, &pMargins->cxRightWidth);
1373 MSSTYLES_GetNextInteger(lpCur, lpEnd, &lpCur, &pMargins->cyTopHeight);
1374 if(!MSSTYLES_GetNextInteger(lpCur, lpEnd, &lpCur, &pMargins->cyBottomHeight)) {
1375 TRACE("Could not parse margins property\n");
1376 return E_PROP_ID_UNSUPPORTED;
1378 return S_OK;