4 * Copyright 2006 - 2007 Thomas Weidenmueller <w3seek@reactos.org>
5 * 2015 Robert Naumann <gonzomdx@gmail.com>
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.
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.
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
24 static void SetBitmap(HWND hwnd
, HBITMAP
* hbmp
, UINT uImageId
)
29 *hbmp
= (HBITMAP
)LoadImageW(hExplorerInstance
,
30 MAKEINTRESOURCEW(uImageId
),
39 GetObject(*hbmp
, sizeof(bm
), &bm
);
40 ::SetWindowPos(hwnd
, NULL
, 0, 0, bm
.bmWidth
+ 2, bm
.bmHeight
+ 2,
41 SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
42 SendMessage(hwnd
, STM_SETIMAGE
, IMAGE_BITMAP
, (LPARAM
)*hbmp
);
47 class CTaskBarSettingsPage
: public CPropertyPageImpl
<CTaskBarSettingsPage
>
50 HBITMAP m_hbmpTaskbar
;
56 BOOL bLock
= IsDlgButtonChecked(IDC_TASKBARPROP_LOCK
);
57 BOOL bHide
= IsDlgButtonChecked(IDC_TASKBARPROP_HIDE
);
58 BOOL bGroup
= IsDlgButtonChecked(IDC_TASKBARPROP_GROUP
);
59 BOOL bShowQL
= IsDlgButtonChecked(IDC_TASKBARPROP_SHOWQL
);
60 BOOL bShowClock
= IsDlgButtonChecked(IDC_TASKBARPROP_CLOCK
);
61 BOOL bShowSeconds
= IsDlgButtonChecked(IDC_TASKBARPROP_SECONDS
);
62 BOOL bHideInactive
= IsDlgButtonChecked(IDC_TASKBARPROP_HIDEICONS
);
65 HWND hwndCustomizeNotifyButton
= GetDlgItem(IDC_TASKBARPROP_ICONCUST
);
66 HWND hwndSeconds
= GetDlgItem(IDC_TASKBARPROP_SECONDS
);
67 HWND hwndTaskbarBitmap
= GetDlgItem(IDC_TASKBARPROP_TASKBARBITMAP
);
68 HWND hwndTrayBitmap
= GetDlgItem(IDC_TASKBARPROP_NOTIFICATIONBITMAP
);
71 uImageId
= IDB_TASKBARPROP_AUTOHIDE
;
72 else if (bLock
&& bGroup
&& bShowQL
)
73 uImageId
= IDB_TASKBARPROP_LOCK_GROUP_QL
;
74 else if (bLock
&& !bGroup
&& !bShowQL
)
75 uImageId
= IDB_TASKBARPROP_LOCK_NOGROUP_NOQL
;
76 else if (bLock
&& bGroup
&& !bShowQL
)
77 uImageId
= IDB_TASKBARPROP_LOCK_GROUP_NOQL
;
78 else if (bLock
&& !bGroup
&& bShowQL
)
79 uImageId
= IDB_TASKBARPROP_LOCK_NOGROUP_QL
;
80 else if (!bLock
&& !bGroup
&& !bShowQL
)
81 uImageId
= IDB_TASKBARPROP_NOLOCK_NOGROUP_NOQL
;
82 else if (!bLock
&& bGroup
&& !bShowQL
)
83 uImageId
= IDB_TASKBARPROP_NOLOCK_GROUP_NOQL
;
84 else if (!bLock
&& !bGroup
&& bShowQL
)
85 uImageId
= IDB_TASKBARPROP_NOLOCK_NOGROUP_QL
;
86 else if (!bLock
&& bGroup
&& bShowQL
)
87 uImageId
= IDB_TASKBARPROP_NOLOCK_GROUP_QL
;
91 SetBitmap(hwndTaskbarBitmap
, &m_hbmpTaskbar
, uImageId
);
93 ::EnableWindow(hwndCustomizeNotifyButton
, bHideInactive
);
94 ::EnableWindow(hwndSeconds
, bShowClock
);
96 CheckDlgButton(IDC_TASKBARPROP_SECONDS
, BST_UNCHECKED
);
98 if (bHideInactive
&& bShowClock
&& bShowSeconds
)
99 uImageId
= IDB_SYSTRAYPROP_HIDE_SECONDS
;
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
;
113 SetBitmap(hwndTrayBitmap
, &m_hbmpTray
, uImageId
);
117 enum { IDD
= IDD_TASKBARPROP_TASKBAR
};
119 BEGIN_MSG_MAP(CTaskBarSettingsPage
)
120 MESSAGE_HANDLER(WM_INITDIALOG
, OnInitDialog
)
121 COMMAND_ID_HANDLER(IDC_TASKBARPROP_ICONCUST
, OnCustomizeTrayIcons
)
122 COMMAND_RANGE_HANDLER(IDC_TASKBARPROP_FIRST_CMD
, IDC_TASKBARPROP_LAST_CMD
, OnCtrlCommand
)
123 CHAIN_MSG_MAP(CPropertyPageImpl
<CTaskBarSettingsPage
>)
126 CTaskBarSettingsPage(HWND hwnd
):
133 ~CTaskBarSettingsPage()
136 DeleteObject(m_hbmpTaskbar
);
138 DeleteObject(m_hbmpTray
);
141 LRESULT
OnInitDialog(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
)
143 CheckDlgButton(IDC_TASKBARPROP_LOCK
, g_TaskbarSettings
.bLock
? BST_CHECKED
: BST_UNCHECKED
);
144 CheckDlgButton(IDC_TASKBARPROP_HIDE
, g_TaskbarSettings
.sr
.AutoHide
? BST_CHECKED
: BST_UNCHECKED
);
145 CheckDlgButton(IDC_TASKBARPROP_ONTOP
, g_TaskbarSettings
.sr
.AlwaysOnTop
? BST_CHECKED
: BST_UNCHECKED
);
146 CheckDlgButton(IDC_TASKBARPROP_GROUP
, g_TaskbarSettings
.bGroupButtons
? BST_CHECKED
: BST_UNCHECKED
);
147 //CheckDlgButton(IDC_TASKBARPROP_SHOWQL, g_TaskbarSettings.bShowQuickLaunch ? BST_CHECKED : BST_UNCHECKED);
148 CheckDlgButton(IDC_TASKBARPROP_CLOCK
, (!g_TaskbarSettings
.sr
.HideClock
) ? BST_CHECKED
: BST_UNCHECKED
);
149 CheckDlgButton(IDC_TASKBARPROP_SECONDS
, g_TaskbarSettings
.bShowSeconds
? BST_CHECKED
: BST_UNCHECKED
);
150 CheckDlgButton(IDC_TASKBARPROP_HIDEICONS
, g_TaskbarSettings
.bHideInactiveIcons
? BST_CHECKED
: BST_UNCHECKED
);
156 LRESULT
OnCustomizeTrayIcons(WORD wNotifyCode
, WORD wID
, HWND hWndCtl
, BOOL
&bHandled
)
158 ShowCustomizeNotifyIcons(hExplorerInstance
, m_hWnd
);
162 LRESULT
OnCtrlCommand(WORD wNotifyCode
, WORD wID
, HWND hWndCtl
, BOOL
&bHandled
)
171 TaskbarSettings newSettings
;
172 memcpy(&newSettings
, &g_TaskbarSettings
, sizeof(TaskbarSettings
));
174 newSettings
.bLock
= IsDlgButtonChecked(IDC_TASKBARPROP_LOCK
);
175 newSettings
.sr
.AutoHide
= IsDlgButtonChecked(IDC_TASKBARPROP_HIDE
);
176 newSettings
.sr
.AlwaysOnTop
= IsDlgButtonChecked(IDC_TASKBARPROP_ONTOP
);
177 newSettings
.bGroupButtons
= IsDlgButtonChecked(IDC_TASKBARPROP_GROUP
);
178 //newSettings.bShowQuickLaunch = IsDlgButtonChecked(IDC_TASKBARPROP_SHOWQL);
179 newSettings
.sr
.HideClock
= !IsDlgButtonChecked(IDC_TASKBARPROP_CLOCK
);
180 newSettings
.bShowSeconds
= IsDlgButtonChecked(IDC_TASKBARPROP_SECONDS
);
181 newSettings
.bHideInactiveIcons
= IsDlgButtonChecked(IDC_TASKBARPROP_HIDEICONS
);
183 SendMessage(m_hwndTaskbar
, TWM_SETTINGSCHANGED
, 0, (LPARAM
)&newSettings
);
185 return PSNRET_NOERROR
;
189 class CStartMenuSettingsPage
: public CPropertyPageImpl
<CStartMenuSettingsPage
>
192 HBITMAP m_hbmpStartBitmap
;
196 HWND hwndCustomizeClassic
= GetDlgItem(IDC_TASKBARPROP_STARTMENUCLASSICCUST
);
197 HWND hwndCustomizeModern
= GetDlgItem(IDC_TASKBARPROP_STARTMENUCUST
);
198 HWND hwndStartBitmap
= GetDlgItem(IDC_TASKBARPROP_STARTMENU_BITMAP
);
199 HWND hwndModernRadioBtn
= GetDlgItem(IDC_TASKBARPROP_STARTMENU
);
200 HWND hwndModernText
= GetDlgItem(IDC_TASKBARPROP_STARTMENUMODERNTEXT
);
201 BOOL policyNoSimpleStartMenu
= SHRestricted(REST_NOSTARTPANEL
) != 0;
202 BOOL bModern
= FALSE
;
204 /* If NoSimpleStartMenu, disable ability to use Modern Start Menu */
205 if (policyNoSimpleStartMenu
)
207 /* Switch to classic */
208 CheckDlgButton(IDC_TASKBARPROP_STARTMENUCLASSIC
, BST_CHECKED
);
210 /* Disable radio button */
211 ::EnableWindow(hwndModernRadioBtn
, FALSE
);
213 /* Hide controls related to modern menu */
214 ::ShowWindow(hwndModernRadioBtn
, SW_HIDE
);
215 ::ShowWindow(hwndModernText
, SW_HIDE
);
216 ::ShowWindow(hwndCustomizeModern
, SW_HIDE
);
218 /* If no restrictions, then get bModern from dialog */
221 bModern
= IsDlgButtonChecked(IDC_TASKBARPROP_STARTMENU
);
224 ::EnableWindow(hwndCustomizeModern
, bModern
);
225 ::EnableWindow(hwndCustomizeClassic
, !bModern
);
227 UINT uImageId
= bModern
? IDB_STARTPREVIEW
: IDB_STARTPREVIEW_CLASSIC
;
228 SetBitmap(hwndStartBitmap
, &m_hbmpStartBitmap
, uImageId
);
232 enum { IDD
= IDD_TASKBARPROP_STARTMENU
};
234 BEGIN_MSG_MAP(CTaskBarSettingsPage
)
235 MESSAGE_HANDLER(WM_INITDIALOG
, OnInitDialog
)
236 COMMAND_ID_HANDLER(IDC_TASKBARPROP_STARTMENUCLASSICCUST
, OnStartMenuCustomize
)
237 CHAIN_MSG_MAP(CPropertyPageImpl
<CStartMenuSettingsPage
>)
240 CStartMenuSettingsPage():
241 m_hbmpStartBitmap(NULL
)
245 ~CStartMenuSettingsPage()
247 if (m_hbmpStartBitmap
)
248 DeleteObject(m_hbmpStartBitmap
);
251 LRESULT
OnInitDialog(UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
&bHandled
)
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!!!!!!!
260 LRESULT
OnStartMenuCustomize(WORD wNotifyCode
, WORD wID
, HWND hWndCtl
, BOOL
&bHandled
)
262 ShowCustomizeClassic(hExplorerInstance
, m_hWnd
);
269 return PSNRET_NOERROR
;
274 PropSheetProc(HWND hwndDlg
, UINT uMsg
, LPARAM lParam
)
276 // NOTE: This callback is needed to set large icon correctly.
280 case PSCB_INITIALIZED
:
282 hIcon
= LoadIconW(hExplorerInstance
, MAKEINTRESOURCEW(IDI_STARTMENU
));
283 SendMessageW(hwndDlg
, WM_SETICON
, ICON_BIG
, (LPARAM
)hIcon
);
291 DisplayTrayProperties(IN HWND hwndOwner
, IN HWND hwndTaskbar
)
294 HPROPSHEETPAGE hpsp
[2];
295 CTaskBarSettingsPage
tbSettingsPage(hwndTaskbar
);
296 CStartMenuSettingsPage smSettingsPage
;
299 caption
.LoadStringW(IDS_TASKBAR_STARTMENU_PROP_CAPTION
);
301 hpsp
[0] = tbSettingsPage
.Create();
302 hpsp
[1] = smSettingsPage
.Create();
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
);
314 psh
.pfnCallback
= PropSheetProc
;