Skip to content

Commit 7c1f7fe

Browse files
committed
Explorer_new changes
- Run dialog in own thread - Fix MapWindowPoints error check - Various TrayWnd Theme svn path=/branches/GSoC_2011/NewExplorer/; revision=52431
1 parent 6fb0e9e commit 7c1f7fe

File tree

1 file changed

+154
-11
lines changed

1 file changed

+154
-11
lines changed

base/shell/explorer-new/traywnd.c

Lines changed: 154 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ typedef struct
4343
const IShellDesktopTrayVtbl *lpVtblShellDesktopTray;
4444
LONG Ref;
4545

46+
HTHEME TaskbarTheme;
4647
HWND hWnd;
4748
HWND hWndDesktop;
4849

@@ -1019,6 +1020,12 @@ ITrayWindowImpl_Destroy(ITrayWindowImpl *This)
10191020
This->TrayBandSite = NULL;
10201021
}
10211022

1023+
if(This->TaskbarTheme)
1024+
{
1025+
CloseThemeData(This->TaskbarTheme);
1026+
This->TaskbarTheme = NULL;
1027+
}
1028+
10221029
ITrayWindowImpl_Release(ITrayWindow_from_impl(This));
10231030

10241031
if (InterlockedDecrement(&TrayWndCount) == 0)
@@ -1105,6 +1112,8 @@ ITrayWindowImpl_AlignControls(IN OUT ITrayWindowImpl *This,
11051112
BOOL Horizontal;
11061113
HDWP dwp;
11071114

1115+
ITrayWindowImpl_UpdateStartButton(This,
1116+
NULL);
11081117
if (prcClient != NULL)
11091118
{
11101119
rcClient = *prcClient;
@@ -1392,12 +1401,26 @@ ITrayWindowImpl_CreateStartButtonBitmap(IN OUT ITrayWindowImpl *This)
13921401

13931402
return hBitmap;
13941403
}
1404+
static VOID
1405+
ITrayWindowImpl_UpdateTheme(IN OUT ITrayWindowImpl *This)
1406+
{
1407+
if(This->TaskbarTheme)
1408+
CloseThemeData(This->TaskbarTheme);
13951409

1410+
if(IsThemeActive())
1411+
This->TaskbarTheme = OpenThemeData(This->hWnd, L"Taskbar");
1412+
else
1413+
This->TaskbarTheme = 0;
1414+
}
13961415
static VOID
13971416
ITrayWindowImpl_Create(IN OUT ITrayWindowImpl *This)
13981417
{
13991418
TCHAR szStartCaption[32];
14001419

1420+
1421+
SetWindowTheme(This->hWnd,L"TaskBar", NULL);
1422+
ITrayWindowImpl_UpdateTheme(This);
1423+
14011424
InterlockedIncrement(&TrayWndCount);
14021425

14031426
if (!LoadString(hExplorerInstance,
@@ -1450,6 +1473,7 @@ ITrayWindowImpl_Create(IN OUT ITrayWindowImpl *This)
14501473
NULL);
14511474
if (This->hwndStart)
14521475
{
1476+
SetWindowTheme(This->hwndStart, L"Start", NULL);
14531477
SendMessage(This->hwndStart,
14541478
WM_SETFONT,
14551479
(WPARAM)This->hStartBtnFont,
@@ -1530,6 +1554,7 @@ ITrayWindowImpl_Create(IN OUT ITrayWindowImpl *This)
15301554
This->TrayBandSite = CreateTrayBandSite(ITrayWindow_from_impl(This),
15311555
&This->hwndRebar,
15321556
&This->hwndTaskSwitch);
1557+
SetWindowTheme(This->hwndRebar,L"TaskBar", NULL);
15331558

15341559
/* Create the tray notification window */
15351560
This->hwndTrayNotify = CreateTrayNotifyWnd(ITrayWindow_from_impl(This),
@@ -1851,6 +1876,105 @@ static const ITrayWindowVtbl ITrayWindowImpl_Vtbl =
18511876
ITrayWindowImpl_Lock
18521877
};
18531878

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+
18541978
static LRESULT CALLBACK
18551979
TrayWndProc(IN HWND hwnd,
18561980
IN UINT uMsg,
@@ -1891,6 +2015,23 @@ TrayWndProc(IN HWND hwnd,
18912015

18922016
switch (uMsg)
18932017
{
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);
18942035
case WM_NCHITTEST:
18952036
{
18962037
RECT rcClient;
@@ -1903,13 +2044,16 @@ TrayWndProc(IN HWND hwnd,
19032044
clicks on the border. */
19042045
return HTBORDER;
19052046
}
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);
19072051
if (GetClientRect(hwnd,
19082052
&rcClient) &&
1909-
MapWindowPoints(hwnd,
2053+
(MapWindowPoints(hwnd,
19102054
NULL,
19112055
(LPPOINT)&rcClient,
1912-
2) != 0)
2056+
2) != 0 || GetLastError()!=0))
19132057
{
19142058
pt.x = (SHORT)LOWORD(lParam);
19152059
pt.y = (SHORT)HIWORD(lParam);
@@ -2005,7 +2149,7 @@ TrayWndProc(IN HWND hwnd,
20052149
case WM_SIZE:
20062150
{
20072151
RECT rcClient;
2008-
2152+
InvalidateRect(This->hWnd, NULL, TRUE);
20092153
if (wParam == SIZE_RESTORED && lParam == 0)
20102154
{
20112155
ITrayWindowImpl_ResizeWorkArea(This);
@@ -2350,13 +2494,12 @@ TrayWndProc(IN HWND hwnd,
23502494

23512495
case IDM_RUN:
23522496
{
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
23602503
break;
23612504
}
23622505

0 commit comments

Comments
 (0)