ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

theme_dialog.c
Go to the documentation of this file.
00001 /*
00002  * Theming - Dialogs
00003  *
00004  * Copyright (c) 2005 by Frank Richter
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00019  *
00020  */
00021 
00022 #include <stdarg.h>
00023 #include <string.h>
00024 #include <stdlib.h>
00025 
00026 #include "windef.h"
00027 #include "winbase.h"
00028 #include "wingdi.h"
00029 #include "winuser.h"
00030 #include "uxtheme.h"
00031 #include "vssym32.h"
00032 #include "comctl32.h"
00033 #include "wine/debug.h"
00034 
00035 /**********************************************************************
00036  * The dialog subclass window proc.
00037  */
00038 LRESULT CALLBACK THEMING_DialogSubclassProc (HWND hWnd, UINT msg, 
00039                                              WPARAM wParam, LPARAM lParam, 
00040                                              ULONG_PTR dwRefData)
00041 {
00042     HTHEME theme = GetWindowTheme ( hWnd );
00043     static const WCHAR themeClass[] = { 'W','i','n','d','o','w',0 };
00044     BOOL themingActive = IsThemeDialogTextureEnabled (hWnd);
00045     BOOL doTheming = themingActive && (theme != NULL);
00046     LRESULT result;
00047       
00048     switch (msg)
00049     {
00050     case WM_CREATE:
00051     result = THEMING_CallOriginalClass (hWnd, msg, wParam, lParam);
00052     theme = OpenThemeData( hWnd, themeClass );
00053     return result;
00054     
00055     case WM_DESTROY:
00056         CloseThemeData ( theme );
00057         SetWindowTheme( hWnd, NULL, NULL );
00058         OpenThemeData( hWnd, NULL );
00059         return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam);
00060 
00061     case WM_THEMECHANGED:
00062         CloseThemeData ( theme );
00063     OpenThemeData( hWnd, themeClass );
00064     InvalidateRect( hWnd, NULL, TRUE );
00065     return 0;
00066     
00067     case WM_SYSCOLORCHANGE:
00068     if (!doTheming) return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam);
00069         /* Do nothing. When themed, a WM_THEMECHANGED will be received, too,
00070      * which will do the repaint. */
00071         break;
00072         
00073     case WM_ERASEBKGND:
00074     if (!doTheming) return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam);
00075         {
00076             RECT rc;
00077             WNDPROC dlgp = (WNDPROC)GetWindowLongPtrW (hWnd, DWLP_DLGPROC);
00078             if (!CallWindowProcW(dlgp, hWnd, msg, wParam, lParam))
00079             {
00080                 /* Draw background*/
00081                 GetClientRect (hWnd, &rc);
00082                 if (IsThemePartDefined (theme, WP_DIALOG, 0))
00083                     /* Although there is a theme for the WINDOW class/DIALOG part, 
00084                      * but I[res] haven't seen Windows using it yet... Even when
00085                      * dialog theming is activated, the good ol' BTNFACE 
00086                      * background seems to be used. */
00087 #if 0
00088                     DrawThemeBackground (theme, (HDC)wParam, WP_DIALOG, 0, &rc, 
00089                         NULL);
00090 #endif
00091                     return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam);
00092                 else 
00093                 /* We might have gotten a TAB theme class, so check if we can 
00094                  * draw as a tab page. */
00095                 if (IsThemePartDefined (theme, TABP_BODY, 0))
00096                     DrawThemeBackground (theme, (HDC)wParam, TABP_BODY, 0, &rc, 
00097                         NULL);
00098                 else
00099                     return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam);
00100             }
00101             return 1;
00102         }
00103 
00104     case WM_CTLCOLORSTATIC:
00105         if (!doTheming) return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam);
00106         {
00107             WNDPROC dlgp = (WNDPROC)GetWindowLongPtrW (hWnd, DWLP_DLGPROC);
00108             LRESULT result = CallWindowProcW(dlgp, hWnd, msg, wParam, lParam);
00109             if (!result)
00110             {
00111                 /* Override defaults with more suitable values when themed */
00112                 HDC controlDC = (HDC)wParam;
00113                 HWND controlWnd = (HWND)lParam;
00114                 WCHAR controlClass[32];
00115                 RECT rc;
00116 
00117                 GetClassNameW (controlWnd, controlClass, 
00118                     sizeof(controlClass) / sizeof(controlClass[0]));
00119                 if (lstrcmpiW (controlClass, WC_STATICW) == 0)
00120                 {
00121                     /* Static control - draw parent background and set text to 
00122                      * transparent, so it looks right on tab pages. */
00123                     GetClientRect (controlWnd, &rc);
00124                     DrawThemeParentBackground (controlWnd, controlDC, &rc);
00125                     SetBkMode (controlDC, TRANSPARENT);
00126 
00127                     /* Return NULL brush since we painted the BG already */
00128                     return (LRESULT)GetStockObject (NULL_BRUSH);
00129                 }
00130                 else
00131                     return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam);
00132 
00133             }
00134             return result;
00135         }
00136 
00137     default: 
00138     /* Call old proc */
00139     return THEMING_CallOriginalClass (hWnd, msg, wParam, lParam);
00140     }
00141     return 0;
00142 }

Generated on Sat May 26 2012 04:21:38 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.