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

trayprop.c
Go to the documentation of this file.
00001 /*
00002  * ReactOS Explorer
00003  *
00004  * Copyright 2006 - 2007 Thomas Weidenmueller <w3seek@reactos.org>
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 Street, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 #include <precomp.h>
00022 
00023 typedef struct _PROPSHEET_INFO
00024 {
00025     HWND hTaskbarWnd;
00026     HWND hStartWnd;
00027     HWND hNotiWnd;
00028     HWND hToolWnd;
00029 
00030     HBITMAP hTaskbarBitmap;
00031 } PROPSHEET_INFO, *PPROPSHEET_INFO;
00032 
00033 
00034 static BOOL
00035 UpdateTaskbarBitmap(PPROPSHEET_INFO pPropInfo)
00036 {
00037     HWND hwndLock, hwndHide, hwndGroup, hwndShowQL;
00038     HWND hwndBitmap;
00039     BOOL bLock, bHide, bGroup, bShowQL;
00040     LPTSTR lpImageName = NULL;
00041     BOOL bRet = FALSE; 
00042 
00043     hwndLock = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_LOCK);
00044     hwndHide = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_HIDE);
00045     hwndGroup = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_GROUP);
00046     hwndShowQL = GetDlgItem(pPropInfo->hTaskbarWnd, IDC_TASKBARPROP_SHOWQL);
00047 
00048     if (hwndLock && hwndHide && hwndGroup && hwndShowQL)
00049     {
00050         bLock = (SendMessage(hwndLock, BM_GETCHECK, 0, 0) == BST_CHECKED);
00051         bHide = (SendMessage(hwndHide, BM_GETCHECK, 0, 0) == BST_CHECKED);
00052         bGroup = (SendMessage(hwndGroup, BM_GETCHECK, 0, 0) == BST_CHECKED);
00053         bShowQL = (SendMessage(hwndShowQL, BM_GETCHECK, 0, 0) == BST_CHECKED);
00054 
00055         if (bHide)
00056             lpImageName = MAKEINTRESOURCE(IDB_TASKBARPROP_AUTOHIDE);
00057         else if (bLock  && bGroup  && bShowQL)
00058             lpImageName = MAKEINTRESOURCE(IDB_TASKBARPROP_LOCK_GROUP_QL);
00059         else if (bLock  && !bGroup && !bShowQL)
00060             lpImageName = MAKEINTRESOURCE(IDB_TASKBARPROP_LOCK_NOGROUP_NOQL);
00061         else if (bLock  && bGroup  && !bShowQL)
00062             lpImageName = MAKEINTRESOURCE(IDB_TASKBARPROP_LOCK_GROUP_NOQL);
00063         else if (bLock  && !bGroup && bShowQL)
00064             lpImageName = MAKEINTRESOURCE(IDB_TASKBARPROP_LOCK_NOGROUP_QL);
00065         else if (!bLock && !bGroup && !bShowQL)
00066             lpImageName = MAKEINTRESOURCE(IDB_TASKBARPROP_NOLOCK_NOGROUP_NOQL);
00067         else if (!bLock && bGroup  && !bShowQL)
00068             lpImageName = MAKEINTRESOURCE(IDB_TASKBARPROP_NOLOCK_GROUP_NOQL);
00069         else if (!bLock && !bGroup && bShowQL)
00070             lpImageName = MAKEINTRESOURCE(IDB_TASKBARPROP_NOLOCK_NOGROUP_QL);
00071         else if (!bLock && bGroup  && bShowQL)
00072             lpImageName = MAKEINTRESOURCE(IDB_TASKBARPROP_NOLOCK_GROUP_QL);
00073 
00074         if (lpImageName)
00075         {
00076             if (pPropInfo->hTaskbarBitmap)
00077             {
00078                 DeleteObject(pPropInfo->hTaskbarBitmap);
00079             }
00080 
00081             pPropInfo->hTaskbarBitmap = LoadImage(hExplorerInstance,
00082                                                   lpImageName,
00083                                                   IMAGE_BITMAP,
00084                                                   0,
00085                                                   0,
00086                                                   LR_DEFAULTCOLOR);
00087             if (pPropInfo->hTaskbarBitmap)
00088             {
00089                 hwndBitmap = GetDlgItem(pPropInfo->hTaskbarWnd,
00090                                         IDC_TASKBARPROP_TASKBARBITMAP);
00091                 if (hwndBitmap)
00092                 {
00093                     SendMessage(hwndBitmap,
00094                                 STM_SETIMAGE,
00095                                 IMAGE_BITMAP,
00096                                 (LPARAM)pPropInfo->hTaskbarBitmap);
00097                 }
00098             }
00099         }
00100     }
00101 
00102     return bRet;
00103 }
00104 
00105 static VOID
00106 OnCreateTaskbarPage(HWND hwnd,
00107                     PPROPSHEET_INFO pPropInfo)
00108 {
00109     SetWindowLongPtr(hwnd,
00110                      GWLP_USERDATA,
00111                      (LONG_PTR)pPropInfo);
00112 
00113     pPropInfo->hTaskbarWnd = hwnd;
00114 
00115     // FIXME: check buttons
00116 
00117     UpdateTaskbarBitmap(pPropInfo);
00118 }
00119 
00120 INT_PTR CALLBACK
00121 TaskbarPageProc(HWND hwndDlg,
00122                 UINT uMsg,
00123                 WPARAM wParam,
00124                 LPARAM lParam)
00125 {
00126     PPROPSHEET_INFO pPropInfo;
00127 
00128     /* Get the window context */
00129     pPropInfo = (PPROPSHEET_INFO)GetWindowLongPtrW(hwndDlg,
00130                                                    GWLP_USERDATA);
00131     if (pPropInfo == NULL && uMsg != WM_INITDIALOG)
00132     {
00133         goto HandleDefaultMessage;
00134     }
00135 
00136     switch (uMsg)
00137     {
00138         case WM_INITDIALOG:
00139             OnCreateTaskbarPage(hwndDlg, (PPROPSHEET_INFO)lParam);
00140             break;
00141 
00142         case WM_COMMAND:
00143             switch(LOWORD(wParam))
00144             {
00145                 case IDC_TASKBARPROP_LOCK:
00146                 case IDC_TASKBARPROP_HIDE:
00147                 case IDC_TASKBARPROP_GROUP:
00148                 case IDC_TASKBARPROP_SHOWQL:
00149                     if (HIWORD(wParam) == BN_CLICKED)
00150                     {
00151                         UpdateTaskbarBitmap(pPropInfo);
00152 
00153                         /* Enable the 'Apply' button */
00154                         PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
00155                     }
00156                     break;
00157             }
00158             break;
00159 
00160         case WM_NOTIFY:
00161         {
00162             LPNMHDR pnmh = (LPNMHDR)lParam;
00163 
00164             switch(pnmh->code)
00165             {
00166                 case PSN_SETACTIVE:
00167                     break;
00168 
00169                 case PSN_APPLY:
00170                     break;
00171             }
00172 
00173             break;
00174         }
00175 
00176         case WM_DESTROY:
00177             if (pPropInfo->hTaskbarBitmap)
00178             {
00179                 DeleteObject(pPropInfo->hTaskbarBitmap);
00180             }
00181             break;
00182 
00183 HandleDefaultMessage:
00184         default:
00185             return FALSE;
00186     }
00187 
00188     return FALSE;
00189 }
00190 
00191 
00192 INT_PTR CALLBACK
00193 StartMenuPageProc(HWND hwndDlg,
00194                   UINT uMsg,
00195                   WPARAM wParam,
00196                   LPARAM lParam)
00197 {
00198     switch (uMsg)
00199     {
00200         case WM_INITDIALOG:
00201             break;
00202 
00203         case WM_DESTROY:
00204             break;
00205 
00206         case WM_NOTIFY:
00207         {
00208             LPNMHDR pnmh = (LPNMHDR)lParam;
00209 
00210             switch(pnmh->code)
00211             {
00212                 case PSN_SETACTIVE:
00213                     break;
00214 
00215                 case PSN_APPLY:
00216                     break;
00217             }
00218 
00219             break;
00220         }
00221     }
00222 
00223     return FALSE;
00224 }
00225 
00226 
00227 INT_PTR CALLBACK
00228 NotificationPageProc(HWND hwndDlg,
00229                      UINT uMsg,
00230                      WPARAM wParam,
00231                      LPARAM lParam)
00232 {
00233     switch (uMsg)
00234     {
00235         case WM_INITDIALOG:
00236             break;
00237 
00238         case WM_DESTROY:
00239             break;
00240 
00241         case WM_NOTIFY:
00242         {
00243             LPNMHDR pnmh = (LPNMHDR)lParam;
00244 
00245             switch(pnmh->code)
00246             {
00247                 case PSN_SETACTIVE:
00248                     break;
00249 
00250                 case PSN_APPLY:
00251                     break;
00252             }
00253 
00254             break;
00255         }
00256     }
00257 
00258     return FALSE;
00259 }
00260 
00261 
00262 INT_PTR CALLBACK
00263 ToolbarsPageProc(HWND hwndDlg,
00264                  UINT uMsg,
00265                  WPARAM wParam,
00266                  LPARAM lParam)
00267 {
00268     switch (uMsg)
00269     {
00270         case WM_INITDIALOG:
00271             break;
00272 
00273         case WM_DESTROY:
00274             break;
00275 
00276         case WM_NOTIFY:
00277         {
00278             LPNMHDR pnmh = (LPNMHDR)lParam;
00279 
00280             switch(pnmh->code)
00281             {
00282                 case PSN_SETACTIVE:
00283                     break;
00284 
00285                 case PSN_APPLY:
00286                     break;
00287             }
00288 
00289             break;
00290         }
00291     }
00292 
00293     return FALSE;
00294 }
00295 
00296 
00297 static VOID
00298 InitPropSheetPage(PROPSHEETPAGE *psp,
00299                   WORD idDlg,
00300                   DLGPROC DlgProc,
00301                   LPARAM lParam)
00302 {
00303     ZeroMemory(psp, sizeof(PROPSHEETPAGE));
00304     psp->dwSize = sizeof(PROPSHEETPAGE);
00305     psp->dwFlags = PSP_DEFAULT;
00306     psp->hInstance = hExplorerInstance;
00307     psp->pszTemplate = MAKEINTRESOURCE(idDlg);
00308     psp->lParam = lParam;
00309     psp->pfnDlgProc = DlgProc;
00310 }
00311 
00312 
00313 HWND
00314 DisplayTrayProperties(ITrayWindow *Tray)
00315 {
00316     PPROPSHEET_INFO pPropInfo;
00317     PROPSHEETHEADER psh;
00318     PROPSHEETPAGE psp[4];
00319     TCHAR szCaption[256];
00320 
00321     pPropInfo = (PPROPSHEET_INFO)HeapAlloc(hProcessHeap,
00322                                            HEAP_ZERO_MEMORY,
00323                                            sizeof(PROPSHEET_INFO));
00324     if (!pPropInfo)
00325     {
00326         return NULL;
00327     }
00328 
00329     if (!LoadString(hExplorerInstance,
00330                     IDS_TASKBAR_STARTMENU_PROP_CAPTION,
00331                     szCaption,
00332                     sizeof(szCaption) / sizeof(szCaption[0])))
00333     {
00334         HeapFree(hProcessHeap,
00335                  0,
00336                  pPropInfo);
00337 
00338         return NULL;
00339     }
00340 
00341     ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
00342     psh.dwSize = sizeof(PROPSHEETHEADER);
00343     psh.dwFlags =  PSH_PROPSHEETPAGE | PSH_PROPTITLE;
00344     psh.hwndParent = NULL;
00345     psh.hInstance = hExplorerInstance;
00346     psh.hIcon = NULL;
00347     psh.pszCaption = szCaption;
00348     psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
00349     psh.nStartPage = 0;
00350     psh.ppsp = psp;
00351 
00352     InitPropSheetPage(&psp[0], IDD_TASKBARPROP_TASKBAR, (DLGPROC)TaskbarPageProc, (LPARAM)pPropInfo);
00353     InitPropSheetPage(&psp[1], IDD_TASKBARPROP_STARTMENU, (DLGPROC)StartMenuPageProc, (LPARAM)pPropInfo);
00354     InitPropSheetPage(&psp[2], IDD_TASKBARPROP_NOTIFICATION, (DLGPROC)NotificationPageProc, (LPARAM)pPropInfo);
00355     InitPropSheetPage(&psp[3], IDD_TASKBARPROP_TOOLBARS, (DLGPROC)ToolbarsPageProc, (LPARAM)pPropInfo);
00356 
00357     PropertySheet(&psh);
00358 
00359     HeapFree(hProcessHeap,
00360              0,
00361              pPropInfo);
00362 
00363     // FIXME: return the HWND
00364     return NULL;
00365 }

Generated on Sat May 26 2012 04:17:24 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.