@@ -43,6 +43,7 @@ typedef struct
43
43
const IShellDesktopTrayVtbl * lpVtblShellDesktopTray ;
44
44
LONG Ref ;
45
45
46
+ HTHEME TaskbarTheme ;
46
47
HWND hWnd ;
47
48
HWND hWndDesktop ;
48
49
@@ -1019,6 +1020,12 @@ ITrayWindowImpl_Destroy(ITrayWindowImpl *This)
1019
1020
This -> TrayBandSite = NULL ;
1020
1021
}
1021
1022
1023
+ if (This -> TaskbarTheme )
1024
+ {
1025
+ CloseThemeData (This -> TaskbarTheme );
1026
+ This -> TaskbarTheme = NULL ;
1027
+ }
1028
+
1022
1029
ITrayWindowImpl_Release (ITrayWindow_from_impl (This ));
1023
1030
1024
1031
if (InterlockedDecrement (& TrayWndCount ) == 0 )
@@ -1105,6 +1112,8 @@ ITrayWindowImpl_AlignControls(IN OUT ITrayWindowImpl *This,
1105
1112
BOOL Horizontal ;
1106
1113
HDWP dwp ;
1107
1114
1115
+ ITrayWindowImpl_UpdateStartButton (This ,
1116
+ NULL );
1108
1117
if (prcClient != NULL )
1109
1118
{
1110
1119
rcClient = * prcClient ;
@@ -1392,12 +1401,26 @@ ITrayWindowImpl_CreateStartButtonBitmap(IN OUT ITrayWindowImpl *This)
1392
1401
1393
1402
return hBitmap ;
1394
1403
}
1404
+ static VOID
1405
+ ITrayWindowImpl_UpdateTheme (IN OUT ITrayWindowImpl * This )
1406
+ {
1407
+ if (This -> TaskbarTheme )
1408
+ CloseThemeData (This -> TaskbarTheme );
1395
1409
1410
+ if (IsThemeActive ())
1411
+ This -> TaskbarTheme = OpenThemeData (This -> hWnd , L"Taskbar" );
1412
+ else
1413
+ This -> TaskbarTheme = 0 ;
1414
+ }
1396
1415
static VOID
1397
1416
ITrayWindowImpl_Create (IN OUT ITrayWindowImpl * This )
1398
1417
{
1399
1418
TCHAR szStartCaption [32 ];
1400
1419
1420
+
1421
+ SetWindowTheme (This -> hWnd ,L"TaskBar" , NULL );
1422
+ ITrayWindowImpl_UpdateTheme (This );
1423
+
1401
1424
InterlockedIncrement (& TrayWndCount );
1402
1425
1403
1426
if (!LoadString (hExplorerInstance ,
@@ -1450,6 +1473,7 @@ ITrayWindowImpl_Create(IN OUT ITrayWindowImpl *This)
1450
1473
NULL );
1451
1474
if (This -> hwndStart )
1452
1475
{
1476
+ SetWindowTheme (This -> hwndStart , L"Start" , NULL );
1453
1477
SendMessage (This -> hwndStart ,
1454
1478
WM_SETFONT ,
1455
1479
(WPARAM )This -> hStartBtnFont ,
@@ -1530,6 +1554,7 @@ ITrayWindowImpl_Create(IN OUT ITrayWindowImpl *This)
1530
1554
This -> TrayBandSite = CreateTrayBandSite (ITrayWindow_from_impl (This ),
1531
1555
& This -> hwndRebar ,
1532
1556
& This -> hwndTaskSwitch );
1557
+ SetWindowTheme (This -> hwndRebar ,L"TaskBar" , NULL );
1533
1558
1534
1559
/* Create the tray notification window */
1535
1560
This -> hwndTrayNotify = CreateTrayNotifyWnd (ITrayWindow_from_impl (This ),
@@ -1851,6 +1876,105 @@ static const ITrayWindowVtbl ITrayWindowImpl_Vtbl =
1851
1876
ITrayWindowImpl_Lock
1852
1877
};
1853
1878
1879
+ static int ITrayWindowImpl_DrawBackground (IN ITrayWindowImpl * This ,
1880
+ IN HDC dc )
1881
+ {
1882
+ int backoundPart ;
1883
+ RECT rect ;
1884
+
1885
+ GetClientRect (This -> hWnd , & rect );
1886
+ switch (This -> Position )
1887
+ {
1888
+ case ABE_LEFT :
1889
+ backoundPart = TBP_BACKGROUNDLEFT ;
1890
+ break ;
1891
+ case ABE_TOP :
1892
+ backoundPart = TBP_BACKGROUNDTOP ;
1893
+ break ;
1894
+ case ABE_RIGHT :
1895
+ backoundPart = TBP_BACKGROUNDRIGHT ;
1896
+ break ;
1897
+ case ABE_BOTTOM :
1898
+ default :
1899
+ backoundPart = TBP_BACKGROUNDBOTTOM ;
1900
+ break ;
1901
+ }
1902
+ DrawThemeBackground (This -> TaskbarTheme , dc , backoundPart , 0 , & rect , 0 );
1903
+ return 0 ;
1904
+ }
1905
+
1906
+ static int ITrayWindowImpl_DrawSizer (IN ITrayWindowImpl * This ,
1907
+ IN HRGN hRgn )
1908
+ {
1909
+ HDC hdc ;
1910
+ RECT rect ;
1911
+ int backoundPart ;
1912
+
1913
+ GetWindowRect (This -> hWnd , & rect );
1914
+ OffsetRect (& rect , - rect .left , - rect .top );
1915
+
1916
+ hdc = GetDCEx (This -> hWnd , hRgn , DCX_WINDOW |DCX_INTERSECTRGN |DCX_PARENTCLIP );
1917
+
1918
+ switch (This -> Position )
1919
+ {
1920
+ case ABE_LEFT :
1921
+ backoundPart = TBP_SIZINGBARLEFT ;
1922
+ rect .left = rect .right - GetSystemMetrics (SM_CXSIZEFRAME );
1923
+ break ;
1924
+ case ABE_TOP :
1925
+ backoundPart = TBP_SIZINGBARTOP ;
1926
+ rect .top = rect .bottom - GetSystemMetrics (SM_CYSIZEFRAME );
1927
+ break ;
1928
+ case ABE_RIGHT :
1929
+ backoundPart = TBP_SIZINGBARRIGHT ;
1930
+ rect .right = rect .left + GetSystemMetrics (SM_CXSIZEFRAME );
1931
+ break ;
1932
+ case ABE_BOTTOM :
1933
+ default :
1934
+ backoundPart = TBP_SIZINGBARBOTTOM ;
1935
+ rect .bottom = rect .top + GetSystemMetrics (SM_CYSIZEFRAME );
1936
+ break ;
1937
+ }
1938
+
1939
+ DrawThemeBackground (This -> TaskbarTheme , hdc , backoundPart , 0 , & rect , 0 );
1940
+
1941
+ ReleaseDC (This -> hWnd , hdc );
1942
+ return 0 ;
1943
+ }
1944
+ DWORD WINAPI RunFileDlgThread ( LPVOID lpParam )
1945
+ {
1946
+ ITrayWindowImpl * This = (ITrayWindowImpl * )lpParam ;
1947
+ HANDLE hShell32 ;
1948
+ RUNFILEDLG RunFileDlg ;
1949
+ HWND hwnd ;
1950
+ RECT posRect ;
1951
+
1952
+ GetWindowRect (This -> hwndStart ,& posRect );
1953
+
1954
+ hwnd = CreateWindowEx (0 ,
1955
+ WC_STATIC ,
1956
+ NULL ,
1957
+ WS_OVERLAPPED | WS_DISABLED | WS_CLIPSIBLINGS | WS_BORDER | SS_LEFT ,
1958
+ posRect .left ,
1959
+ posRect .top ,
1960
+ posRect .right - posRect .left ,
1961
+ posRect .bottom - posRect .top ,
1962
+ NULL ,
1963
+ NULL ,
1964
+ NULL ,
1965
+ NULL );
1966
+
1967
+ hShell32 = GetModuleHandle (TEXT ("SHELL32.DLL" ));
1968
+ RunFileDlg = (RUNFILEDLG )GetProcAddress (hShell32 , (LPCSTR )61 );
1969
+
1970
+ RunFileDlg (hwnd , NULL , NULL , NULL , NULL , RFF_CALCDIRECTORY );
1971
+
1972
+ DestroyWindow (hwnd );
1973
+
1974
+ return 0 ;
1975
+ }
1976
+
1977
+
1854
1978
static LRESULT CALLBACK
1855
1979
TrayWndProc (IN HWND hwnd ,
1856
1980
IN UINT uMsg ,
@@ -1891,6 +2015,23 @@ TrayWndProc(IN HWND hwnd,
1891
2015
1892
2016
switch (uMsg )
1893
2017
{
2018
+
2019
+ case WM_THEMECHANGED :
2020
+ ITrayWindowImpl_UpdateTheme (This );
2021
+ return 0 ;
2022
+ case WM_NCPAINT :
2023
+ if (!This -> TaskbarTheme )
2024
+ goto DefHandler ;
2025
+ return ITrayWindowImpl_DrawSizer (This ,
2026
+ (HRGN )wParam );
2027
+ case WM_ERASEBKGND :
2028
+ if (!This -> TaskbarTheme )
2029
+ goto DefHandler ;
2030
+ return ITrayWindowImpl_DrawBackground (This ,
2031
+ (HDC )wParam );
2032
+ case WM_CTLCOLORBTN :
2033
+ SetBkMode ((HDC )wParam , TRANSPARENT );
2034
+ return (int )GetStockObject (HOLLOW_BRUSH );
1894
2035
case WM_NCHITTEST :
1895
2036
{
1896
2037
RECT rcClient ;
@@ -1903,13 +2044,16 @@ TrayWndProc(IN HWND hwnd,
1903
2044
clicks on the border. */
1904
2045
return HTBORDER ;
1905
2046
}
1906
-
2047
+
2048
+ /* 0 is a possible valid response for MapWindowPoints.
2049
+ While the default error code is 0. An extra check needs to be done */
2050
+ SetLastError (-1 );
1907
2051
if (GetClientRect (hwnd ,
1908
2052
& rcClient ) &&
1909
- MapWindowPoints (hwnd ,
2053
+ ( MapWindowPoints (hwnd ,
1910
2054
NULL ,
1911
2055
(LPPOINT )& rcClient ,
1912
- 2 ) != 0 )
2056
+ 2 ) != 0 || GetLastError () != 0 ) )
1913
2057
{
1914
2058
pt .x = (SHORT )LOWORD (lParam );
1915
2059
pt .y = (SHORT )HIWORD (lParam );
@@ -2005,7 +2149,7 @@ TrayWndProc(IN HWND hwnd,
2005
2149
case WM_SIZE :
2006
2150
{
2007
2151
RECT rcClient ;
2008
-
2152
+ InvalidateRect ( This -> hWnd , NULL , TRUE);
2009
2153
if (wParam == SIZE_RESTORED && lParam == 0 )
2010
2154
{
2011
2155
ITrayWindowImpl_ResizeWorkArea (This );
@@ -2350,13 +2494,12 @@ TrayWndProc(IN HWND hwnd,
2350
2494
2351
2495
case IDM_RUN :
2352
2496
{
2353
- HANDLE hShell32 ;
2354
- RUNFILEDLG RunFileDlg ;
2355
-
2356
- hShell32 = GetModuleHandle (TEXT ("SHELL32.DLL" ));
2357
- RunFileDlg = (RUNFILEDLG )GetProcAddress (hShell32 , (LPCSTR )61 );
2358
-
2359
- RunFileDlg (hwnd , NULL , NULL , NULL , NULL , RFF_CALCDIRECTORY );
2497
+ CreateThread (NULL , // default security attributes
2498
+ 0 , // use default stack size
2499
+ RunFileDlgThread , // thread function name
2500
+ This , // argument to thread function
2501
+ 0 , // use default creation flags
2502
+ NULL ); // returns the thread identifier
2360
2503
break ;
2361
2504
}
2362
2505
0 commit comments