ReactOS  0.4.14-dev-384-g5b37caa
trayprop.cpp
Go to the documentation of this file.
1 /*
2  * ReactOS Explorer
3  *
4  * Copyright 2006 - 2007 Thomas Weidenmueller <w3seek@reactos.org>
5  * 2015 Robert Naumann <gonzomdx@gmail.com>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "precomp.h"
23 
24 static void SetBitmap(HWND hwnd, HBITMAP* hbmp, UINT uImageId)
25 {
26  if (*hbmp)
28 
30  MAKEINTRESOURCEW(uImageId),
32  0,
33  0,
35 
36  if (*hbmp && hwnd)
37  {
38  BITMAP bm;
39  GetObject(*hbmp, sizeof(bm), &bm);
40  ::SetWindowPos(hwnd, NULL, 0, 0, bm.bmWidth + 2, bm.bmHeight + 2,
43  }
44 
45 }
46 
47 class CTaskBarSettingsPage : public CPropertyPageImpl<CTaskBarSettingsPage>
48 {
49 private:
53 
54  void UpdateDialog()
55  {
63  UINT uImageId;
64 
65  HWND hwndCustomizeNotifyButton = GetDlgItem(IDC_TASKBARPROP_ICONCUST);
67  HWND hwndTaskbarBitmap = GetDlgItem(IDC_TASKBARPROP_TASKBARBITMAP);
69 
70  if (bHide)
71  uImageId = IDB_TASKBARPROP_AUTOHIDE;
72  else if (bLock && bGroup && bShowQL)
74  else if (bLock && !bGroup && !bShowQL)
76  else if (bLock && bGroup && !bShowQL)
78  else if (bLock && !bGroup && bShowQL)
80  else if (!bLock && !bGroup && !bShowQL)
82  else if (!bLock && bGroup && !bShowQL)
84  else if (!bLock && !bGroup && bShowQL)
86  else if (!bLock && bGroup && bShowQL)
88  else
89  ASSERT(FALSE);
90 
91  SetBitmap(hwndTaskbarBitmap, &m_hbmpTaskbar, uImageId);
92 
93  ::EnableWindow(hwndCustomizeNotifyButton, bHideInactive);
94  ::EnableWindow(hwndSeconds, bShowClock);
95  if (!bShowSeconds)
97 
98  if (bHideInactive && bShowClock && bShowSeconds)
100  else if (bHideInactive && bShowClock && !bShowSeconds)
101  uImageId = IDB_SYSTRAYPROP_HIDE_CLOCK;
102  else if (bHideInactive && !bShowClock)
103  uImageId = IDB_SYSTRAYPROP_HIDE_NOCLOCK;
104  else if (!bHideInactive && bShowClock && bShowSeconds)
105  uImageId = IDB_SYSTRAYPROP_SHOW_SECONDS;
106  else if (!bHideInactive && bShowClock && !bShowSeconds)
107  uImageId = IDB_SYSTRAYPROP_SHOW_CLOCK;
108  else if (!bHideInactive && !bShowClock)
109  uImageId = IDB_SYSTRAYPROP_SHOW_NOCLOCK;
110  else
111  ASSERT(FALSE);
112 
113  SetBitmap(hwndTrayBitmap, &m_hbmpTray, uImageId);
114  }
115 
116 public:
118 
124  END_MSG_MAP()
125 
128  m_hbmpTray(NULL),
130  {
131  }
132 
134  {
135  if (m_hbmpTaskbar)
137  if (m_hbmpTray)
139  }
140 
142  {
147  //CheckDlgButton(IDC_TASKBARPROP_SHOWQL, g_TaskbarSettings.bShowQuickLaunch ? BST_CHECKED : BST_UNCHECKED);
151 
152  UpdateDialog();
153  return TRUE;
154  }
155 
156  LRESULT OnCustomizeTrayIcons(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
157  {
159  return 0;
160  }
161 
162  LRESULT OnCtrlCommand(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
163  {
164  UpdateDialog();
165  SetModified(TRUE);
166  return 0;
167  }
168 
169  int OnApply()
170  {
171  TaskbarSettings newSettings;
172  memcpy(&newSettings, &g_TaskbarSettings, sizeof(TaskbarSettings));
173 
178  //newSettings.bShowQuickLaunch = IsDlgButtonChecked(IDC_TASKBARPROP_SHOWQL);
182 
184 
185  return PSNRET_NOERROR;
186  }
187 };
188 
189 class CStartMenuSettingsPage : public CPropertyPageImpl<CStartMenuSettingsPage>
190 {
191 private:
193 
195  {
196  HWND hwndCustomizeClassic = GetDlgItem(IDC_TASKBARPROP_STARTMENUCLASSICCUST);
197  HWND hwndCustomizeModern = GetDlgItem(IDC_TASKBARPROP_STARTMENUCUST);
199  HWND hwndModernRadioBtn = GetDlgItem(IDC_TASKBARPROP_STARTMENU);
201  BOOL policyNoSimpleStartMenu = SHRestricted(REST_NOSTARTPANEL) != 0;
202  BOOL bModern = FALSE;
203 
204  /* If NoSimpleStartMenu, disable ability to use Modern Start Menu */
205  if (policyNoSimpleStartMenu)
206  {
207  /* Switch to classic */
209 
210  /* Disable radio button */
211  ::EnableWindow(hwndModernRadioBtn, FALSE);
212 
213  /* Hide controls related to modern menu */
214  ::ShowWindow(hwndModernRadioBtn, SW_HIDE);
215  ::ShowWindow(hwndModernText, SW_HIDE);
216  ::ShowWindow(hwndCustomizeModern, SW_HIDE);
217  }
218  /* If no restrictions, then get bModern from dialog */
219  else
220  {
222  }
223 
224  ::EnableWindow(hwndCustomizeModern, bModern);
225  ::EnableWindow(hwndCustomizeClassic, !bModern);
226 
227  UINT uImageId = bModern ? IDB_STARTPREVIEW : IDB_STARTPREVIEW_CLASSIC;
228  SetBitmap(hwndStartBitmap, &m_hbmpStartBitmap, uImageId);
229  }
230 
231 public:
233 
238  END_MSG_MAP()
239 
242  {
243  }
244 
246  {
247  if (m_hbmpStartBitmap)
249  }
250 
252  {
253  // fix me: start menu style (classic/modern) should be read somewhere from the registry.
254  CheckDlgButton(IDC_TASKBARPROP_STARTMENUCLASSIC, BST_CHECKED); // HACK: This has to be read from registry!!!!!!!
255  UpdateDialog();
256 
257  return TRUE;
258  }
259 
260  LRESULT OnStartMenuCustomize(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
261  {
263  return 0;
264  }
265 
266  int OnApply()
267  {
268  //TODO
269  return PSNRET_NOERROR;
270  }
271 };
272 
273 static int CALLBACK
275 {
276  // NOTE: This callback is needed to set large icon correctly.
277  HICON hIcon;
278  switch (uMsg)
279  {
280  case PSCB_INITIALIZED:
281  {
283  SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
284  break;
285  }
286  }
287  return 0;
288 }
289 
290 VOID
291 DisplayTrayProperties(IN HWND hwndOwner, IN HWND hwndTaskbar)
292 {
293  PROPSHEETHEADER psh;
294  HPROPSHEETPAGE hpsp[2];
295  CTaskBarSettingsPage tbSettingsPage(hwndTaskbar);
296  CStartMenuSettingsPage smSettingsPage;
297  CStringW caption;
298 
299  caption.LoadStringW(IDS_TASKBAR_STARTMENU_PROP_CAPTION);
300 
301  hpsp[0] = tbSettingsPage.Create();
302  hpsp[1] = smSettingsPage.Create();
303 
304  ZeroMemory(&psh, sizeof(psh));
305  psh.dwSize = sizeof(psh);
306  psh.dwFlags = PSH_PROPTITLE | PSH_USEICONID | PSH_USECALLBACK;
307  psh.hwndParent = hwndOwner;
308  psh.hInstance = hExplorerInstance;
309  psh.pszIcon = MAKEINTRESOURCEW(IDI_STARTMENU);
310  psh.pszCaption = caption.GetString();
311  psh.nPages = _countof(hpsp);
312  psh.nStartPage = 0;
313  psh.phpage = hpsp;
314  psh.pfnCallback = PropSheetProc;
315 
316  PropertySheet(&psh);
317 }
#define IDB_STARTPREVIEW_CLASSIC
Definition: resource.h:46
HPROPSHEETPAGE Create()
Definition: rosdlgs.h:57
#define IDC_TASKBARPROP_ONTOP
Definition: resource.h:114
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define IN
Definition: typedefs.h:38
static HICON
Definition: imagelist.c:84
#define IDC_TASKBARPROP_STARTMENUMODERNTEXT
Definition: resource.h:127
#define TRUE
Definition: types.h:120
DWORD HideClock
Definition: precomp.h:195
#define IDC_TASKBARPROP_STARTMENU
Definition: resource.h:129
UINT IsDlgButtonChecked(int nIDButton) const
Definition: atlwin.h:858
#define IDB_TASKBARPROP_LOCK_NOGROUP_NOQL
Definition: resource.h:40
LRESULT OnCustomizeTrayIcons(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
Definition: trayprop.cpp:156
#define SW_HIDE
Definition: winuser.h:762
#define _countof(array)
Definition: fontsub.cpp:30
#define IDC_TASKBARPROP_FIRST_CMD
Definition: resource.h:111
VOID ShowCustomizeNotifyIcons(HINSTANCE hInst, HWND hExplorer)
BOOL EnableWindow(BOOL bEnable=TRUE)
Definition: atlwin.h:489
#define CALLBACK
Definition: compat.h:27
#define IDI_STARTMENU
Definition: resource.h:14
#define IDB_TASKBARPROP_NOLOCK_NOGROUP_QL
Definition: resource.h:37
#define COMMAND_RANGE_HANDLER(idFirst, idLast, func)
Definition: atlwin.h:1843
#define ZeroMemory
Definition: winbase.h:1642
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
UINT_PTR WPARAM
Definition: windef.h:207
#define SWP_NOZORDER
Definition: winuser.h:1232
BOOL bShowSeconds
Definition: precomp.h:207
#define PSH_USECALLBACK
Definition: prsht.h:48
#define IDC_TASKBARPROP_TASKBARBITMAP
Definition: resource.h:122
TW_STRUCKRECTS2 sr
Definition: precomp.h:209
WPARAM wParam
Definition: combotst.c:138
#define IDC_TASKBARPROP_STARTMENU_BITMAP
Definition: resource.h:132
#define IDB_TASKBARPROP_AUTOHIDE
Definition: resource.h:33
VOID ShowCustomizeClassic(HINSTANCE, HWND)
#define IDB_TASKBARPROP_LOCK_GROUP_NOQL
Definition: resource.h:38
#define PSH_USEICONID
Definition: prsht.h:42
#define IDB_SYSTRAYPROP_SHOW_NOCLOCK
Definition: resource.h:50
#define TWM_SETTINGSCHANGED
Definition: precomp.h:132
unsigned int BOOL
Definition: ntddk_ex.h:94
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
BOOL CheckDlgButton(int nIDButton, UINT nCheck)
Definition: atlwin.h:335
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: trayprop.cpp:141
DWORD AutoHide
Definition: precomp.h:192
#define IDC_TASKBARPROP_HIDE
Definition: resource.h:115
VOID DisplayTrayProperties(IN HWND hwndOwner, IN HWND hwndTaskbar)
Definition: trayprop.cpp:291
smooth NULL
Definition: ftsmooth.c:416
TaskbarSettings g_TaskbarSettings
Definition: settings.cpp:23
#define PROPSHEETHEADER
Definition: prsht.h:374
#define IDB_TASKBARPROP_NOLOCK_GROUP_NOQL
Definition: resource.h:39
LONG_PTR LPARAM
Definition: windef.h:208
#define COMMAND_ID_HANDLER(id, func)
Definition: atlwin.h:1825
#define IDB_TASKBARPROP_NOLOCK_NOGROUP_NOQL
Definition: resource.h:41
DWORD AlwaysOnTop
Definition: precomp.h:193
#define IDB_TASKBARPROP_NOLOCK_GROUP_QL
Definition: resource.h:35
HWND GetDlgItem(int nID)
Definition: atlwin.h:571
#define IDD_TASKBARPROP_STARTMENU
Definition: resource.h:89
#define IDC_TASKBARPROP_LAST_CMD
Definition: resource.h:121
HBITMAP hbmp
BOOL bHideInactiveIcons
Definition: precomp.h:208
#define IDB_SYSTRAYPROP_HIDE_SECONDS
Definition: resource.h:43
#define IDC_TASKBARPROP_ICONCUST
Definition: resource.h:113
#define IDC_TASKBARPROP_NOTIFICATIONBITMAP
Definition: resource.h:123
#define PSH_PROPTITLE
Definition: prsht.h:40
#define END_MSG_MAP()
Definition: atlwin.h:1789
#define SWP_NOACTIVATE
Definition: winuser.h:1227
HINSTANCE hExplorerInstance
Definition: explorer.cpp:24
PCXSTR GetString() const
Definition: atlsimpstr.h:361
#define IDC_TASKBARPROP_HIDEICONS
Definition: resource.h:112
BOOL bGroupButtons
Definition: precomp.h:206
unsigned short WORD
Definition: ntddk_ex.h:93
#define IDC_TASKBARPROP_GROUP
Definition: resource.h:117
#define IDB_STARTPREVIEW
Definition: resource.h:45
#define GetObject
Definition: wingdi.h:4463
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define PSNRET_NOERROR
Definition: prsht.h:129
#define IDC_TASKBARPROP_STARTMENUCLASSICCUST
Definition: resource.h:126
#define IDC_TASKBARPROP_STARTMENUCUST
Definition: resource.h:128
#define IDC_TASKBARPROP_CLOCK
Definition: resource.h:116
#define CHAIN_MSG_MAP(theChainClass)
Definition: atlwin.h:1870
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
HWND m_hWnd
Definition: atlwin.h:268
#define IDC_TASKBARPROP_SECONDS
Definition: resource.h:119
#define BST_UNCHECKED
Definition: winuser.h:199
#define IDB_SYSTRAYPROP_SHOW_CLOCK
Definition: resource.h:49
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: trayprop.cpp:251
#define IDC_TASKBARPROP_STARTMENUCLASSIC
Definition: resource.h:130
#define IDC_TASKBARPROP_SHOWQL
Definition: resource.h:120
#define IDB_SYSTRAYPROP_HIDE_NOCLOCK
Definition: resource.h:48
#define PSCB_INITIALIZED
Definition: prsht.h:75
BOOL ShowWindow(int nCmdShow)
Definition: atlwin.h:1265
HICON hIcon
Definition: msconfig.c:44
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
Definition: bl.h:1331
#define IDB_TASKBARPROP_LOCK_GROUP_QL
Definition: resource.h:34
#define IDB_SYSTRAYPROP_SHOW_SECONDS
Definition: resource.h:42
unsigned int UINT
Definition: ndis.h:50
#define IMAGE_BITMAP
Definition: winuser.h:211
#define STM_SETIMAGE
Definition: winuser.h:2075
#define BST_CHECKED
Definition: winuser.h:197
#define BEGIN_MSG_MAP(theClass)
Definition: atlwin.h:1770
LRESULT OnCtrlCommand(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
Definition: trayprop.cpp:162
#define IDD_TASKBARPROP_TASKBAR
Definition: resource.h:85
#define MESSAGE_HANDLER(msg, func)
Definition: atlwin.h:1798
#define SendMessage
Definition: winuser.h:5744
#define PropertySheet
Definition: prsht.h:382
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1048
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define IDC_TASKBARPROP_LOCK
Definition: resource.h:118
#define SWP_NOMOVE
Definition: winuser.h:1229
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
static HBITMAP
Definition: button.c:44
static int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
Definition: trayprop.cpp:274
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
void SetModified(BOOL bChanged=TRUE)
Definition: rosdlgs.h:67
LONG_PTR LRESULT
Definition: windef.h:209
#define LR_DEFAULTCOLOR
Definition: winuser.h:1077
LRESULT OnStartMenuCustomize(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
Definition: trayprop.cpp:260
DWORD WINAPI SHRestricted(RESTRICTIONS policy)
Definition: shpolicy.c:836
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define IDS_TASKBAR_STARTMENU_PROP_CAPTION
Definition: resource.h:103
#define IDB_TASKBARPROP_LOCK_NOGROUP_QL
Definition: resource.h:36
#define ICON_BIG
Definition: tnclass.cpp:51
static void SetBitmap(HWND hwnd, HBITMAP *hbmp, UINT uImageId)
Definition: trayprop.cpp:24
#define IDB_SYSTRAYPROP_HIDE_CLOCK
Definition: resource.h:47