[UXTHEME] -Rename WND_CONTEXT to WND_DATA to avoid confusion with the DRAW_CONTEXT. The WND_DATA is information valid throughout the life of a window and DRAW_CONTEXT is information throughout a draw operation in the non client area of the window.

svn path=/trunk/; revision=74587
This commit is contained in:
Giannis Adamopoulos 2017-05-19 08:45:49 +00:00
parent 68bca6631d
commit a652c58c19
4 changed files with 135 additions and 135 deletions

View file

@ -239,9 +239,9 @@ static void SCROLL_DrawInterior( PDRAW_CONTEXT pcontext, SCROLLBARINFO* psbi,
} }
} }
static void SCROLL_DrawMovingThumb(PWND_CONTEXT pwndContext, PDRAW_CONTEXT pcontext, SCROLLBARINFO* psbi, BOOL vertical) static void SCROLL_DrawMovingThumb(PWND_DATA pwndData, PDRAW_CONTEXT pcontext, SCROLLBARINFO* psbi, BOOL vertical)
{ {
INT pos = pwndContext->SCROLL_TrackingPos; INT pos = pwndData->SCROLL_TrackingPos;
INT max_size; INT max_size;
if( vertical ) if( vertical )
@ -258,7 +258,7 @@ static void SCROLL_DrawMovingThumb(PWND_CONTEXT pwndContext, PDRAW_CONTEXT pcont
SCROLL_DrawInterior(pcontext, psbi, pos, vertical, SCROLL_THUMB, 0); SCROLL_DrawInterior(pcontext, psbi, pos, vertical, SCROLL_THUMB, 0);
pwndContext->SCROLL_MovingThumb = !pwndContext->SCROLL_MovingThumb; pwndData->SCROLL_MovingThumb = !pwndData->SCROLL_MovingThumb;
} }
@ -269,15 +269,15 @@ ThemeDrawScrollBar(PDRAW_CONTEXT pcontext, INT nBar, POINT* pt)
SCROLLBARINFO sbi; SCROLLBARINFO sbi;
BOOL vertical; BOOL vertical;
enum SCROLL_HITTEST htHot = SCROLL_NOWHERE; enum SCROLL_HITTEST htHot = SCROLL_NOWHERE;
PWND_CONTEXT pwndContext; PWND_DATA pwndData;
if (((nBar == SB_VERT) && !(pcontext->wi.dwStyle & WS_VSCROLL)) || if (((nBar == SB_VERT) && !(pcontext->wi.dwStyle & WS_VSCROLL)) ||
((nBar == SB_HORZ) && !(pcontext->wi.dwStyle & WS_HSCROLL))) return; ((nBar == SB_HORZ) && !(pcontext->wi.dwStyle & WS_HSCROLL))) return;
if (!(pwndContext = ThemeGetWndContext(pcontext->hWnd))) if (!(pwndData = ThemeGetWndData(pcontext->hWnd)))
return; return;
if (pwndContext->SCROLL_TrackingWin) if (pwndData->SCROLL_TrackingWin)
return; return;
/* Retrieve scrollbar info */ /* Retrieve scrollbar info */
@ -371,7 +371,7 @@ static UINT SCROLL_GetThumbVal( SCROLLINFO *psi, RECT *rect,
} }
static void static void
SCROLL_HandleScrollEvent(PWND_CONTEXT pwndContext, HWND hwnd, INT nBar, UINT msg, POINT pt) SCROLL_HandleScrollEvent(PWND_DATA pwndData, HWND hwnd, INT nBar, UINT msg, POINT pt)
{ {
/* Previous mouse position for timer events */ /* Previous mouse position for timer events */
static POINT prevPt; static POINT prevPt;
@ -401,7 +401,7 @@ SCROLL_HandleScrollEvent(PWND_CONTEXT pwndContext, HWND hwnd, INT nBar, UINT msg
return; return;
} }
if ((pwndContext->SCROLL_trackHitTest == SCROLL_NOWHERE) && (msg != WM_LBUTTONDOWN)) if ((pwndData->SCROLL_trackHitTest == SCROLL_NOWHERE) && (msg != WM_LBUTTONDOWN))
return; return;
ThemeInitDrawContext(&context, hwnd, 0); ThemeInitDrawContext(&context, hwnd, 0);
@ -416,8 +416,8 @@ SCROLL_HandleScrollEvent(PWND_CONTEXT pwndContext, HWND hwnd, INT nBar, UINT msg
{ {
case WM_LBUTTONDOWN: /* Initialise mouse tracking */ case WM_LBUTTONDOWN: /* Initialise mouse tracking */
HideCaret(hwnd); /* hide caret while holding down LBUTTON */ HideCaret(hwnd); /* hide caret while holding down LBUTTON */
pwndContext->SCROLL_trackVertical = vertical; pwndData->SCROLL_trackVertical = vertical;
pwndContext->SCROLL_trackHitTest = hittest = SCROLL_HitTest( hwnd, &sbi, vertical, pt, FALSE ); pwndData->SCROLL_trackHitTest = hittest = SCROLL_HitTest( hwnd, &sbi, vertical, pt, FALSE );
lastClickPos = vertical ? (pt.y - sbi.rcScrollBar.top) : (pt.x - sbi.rcScrollBar.left); lastClickPos = vertical ? (pt.y - sbi.rcScrollBar.top) : (pt.x - sbi.rcScrollBar.left);
lastMousePos = lastClickPos; lastMousePos = lastClickPos;
trackThumbPos = sbi.xyThumbTop; trackThumbPos = sbi.xyThumbTop;
@ -450,15 +450,15 @@ SCROLL_HandleScrollEvent(PWND_CONTEXT pwndContext, HWND hwnd, INT nBar, UINT msg
//TRACE("Event: hwnd=%p bar=%d msg=%s pt=%d,%d hit=%d\n", //TRACE("Event: hwnd=%p bar=%d msg=%s pt=%d,%d hit=%d\n",
// hwnd, nBar, SPY_GetMsgName(msg,hwnd), pt.x, pt.y, hittest ); // hwnd, nBar, SPY_GetMsgName(msg,hwnd), pt.x, pt.y, hittest );
switch(pwndContext->SCROLL_trackHitTest) switch(pwndData->SCROLL_trackHitTest)
{ {
case SCROLL_NOWHERE: /* No tracking in progress */ case SCROLL_NOWHERE: /* No tracking in progress */
break; break;
case SCROLL_TOP_ARROW: case SCROLL_TOP_ARROW:
if (hittest == pwndContext->SCROLL_trackHitTest) if (hittest == pwndData->SCROLL_trackHitTest)
{ {
SCROLL_DrawArrows( &context, &sbi, vertical, pwndContext->SCROLL_trackHitTest, 0 ); SCROLL_DrawArrows( &context, &sbi, vertical, pwndData->SCROLL_trackHitTest, 0 );
if ((msg == WM_LBUTTONDOWN) || (msg == WM_SYSTIMER)) if ((msg == WM_LBUTTONDOWN) || (msg == WM_SYSTIMER))
{ {
SendMessageW( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, SendMessageW( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
@ -477,8 +477,8 @@ SCROLL_HandleScrollEvent(PWND_CONTEXT pwndContext, HWND hwnd, INT nBar, UINT msg
break; break;
case SCROLL_TOP_RECT: case SCROLL_TOP_RECT:
SCROLL_DrawInterior( &context, &sbi, sbi.xyThumbTop, vertical, pwndContext->SCROLL_trackHitTest, 0); SCROLL_DrawInterior( &context, &sbi, sbi.xyThumbTop, vertical, pwndData->SCROLL_trackHitTest, 0);
if (hittest == pwndContext->SCROLL_trackHitTest) if (hittest == pwndData->SCROLL_trackHitTest)
{ {
if ((msg == WM_LBUTTONDOWN) || (msg == WM_SYSTIMER)) if ((msg == WM_LBUTTONDOWN) || (msg == WM_SYSTIMER))
{ {
@ -494,20 +494,20 @@ SCROLL_HandleScrollEvent(PWND_CONTEXT pwndContext, HWND hwnd, INT nBar, UINT msg
case SCROLL_THUMB: case SCROLL_THUMB:
if (msg == WM_LBUTTONDOWN) if (msg == WM_LBUTTONDOWN)
{ {
pwndContext->SCROLL_TrackingWin = hwnd; pwndData->SCROLL_TrackingWin = hwnd;
pwndContext->SCROLL_TrackingBar = nBar; pwndData->SCROLL_TrackingBar = nBar;
pwndContext->SCROLL_TrackingPos = trackThumbPos + lastMousePos - lastClickPos; pwndData->SCROLL_TrackingPos = trackThumbPos + lastMousePos - lastClickPos;
pwndContext->SCROLL_TrackingVal = SCROLL_GetThumbVal( &si, &sbi.rcScrollBar, pwndData->SCROLL_TrackingVal = SCROLL_GetThumbVal( &si, &sbi.rcScrollBar,
vertical, pwndContext->SCROLL_TrackingPos ); vertical, pwndData->SCROLL_TrackingPos );
if (!pwndContext->SCROLL_MovingThumb) if (!pwndData->SCROLL_MovingThumb)
SCROLL_DrawMovingThumb(pwndContext, &context, &sbi, vertical); SCROLL_DrawMovingThumb(pwndData, &context, &sbi, vertical);
} }
else if (msg == WM_LBUTTONUP) else if (msg == WM_LBUTTONUP)
{ {
if (pwndContext->SCROLL_MovingThumb) if (pwndData->SCROLL_MovingThumb)
SCROLL_DrawMovingThumb(pwndContext, &context, &sbi, vertical); SCROLL_DrawMovingThumb(pwndData, &context, &sbi, vertical);
SCROLL_DrawInterior( &context, &sbi, sbi.xyThumbTop, vertical, 0, pwndContext->SCROLL_trackHitTest ); SCROLL_DrawInterior( &context, &sbi, sbi.xyThumbTop, vertical, 0, pwndData->SCROLL_trackHitTest );
} }
else /* WM_MOUSEMOVE */ else /* WM_MOUSEMOVE */
{ {
@ -520,28 +520,28 @@ SCROLL_HandleScrollEvent(PWND_CONTEXT pwndContext, HWND hwnd, INT nBar, UINT msg
pt = SCROLL_ClipPos( &sbi.rcScrollBar, pt ); pt = SCROLL_ClipPos( &sbi.rcScrollBar, pt );
pos = vertical ? (pt.y - sbi.rcScrollBar.top) : (pt.x - sbi.rcScrollBar.left); pos = vertical ? (pt.y - sbi.rcScrollBar.top) : (pt.x - sbi.rcScrollBar.left);
} }
if ( (pos != lastMousePos) || (!pwndContext->SCROLL_MovingThumb) ) if ( (pos != lastMousePos) || (!pwndData->SCROLL_MovingThumb) )
{ {
if (pwndContext->SCROLL_MovingThumb) if (pwndData->SCROLL_MovingThumb)
SCROLL_DrawMovingThumb(pwndContext, &context, &sbi, vertical); SCROLL_DrawMovingThumb(pwndData, &context, &sbi, vertical);
lastMousePos = pos; lastMousePos = pos;
pwndContext->SCROLL_TrackingPos = trackThumbPos + pos - lastClickPos; pwndData->SCROLL_TrackingPos = trackThumbPos + pos - lastClickPos;
pwndContext->SCROLL_TrackingVal = SCROLL_GetThumbVal( &si, &sbi.rcScrollBar, pwndData->SCROLL_TrackingVal = SCROLL_GetThumbVal( &si, &sbi.rcScrollBar,
vertical, vertical,
pwndContext->SCROLL_TrackingPos ); pwndData->SCROLL_TrackingPos );
SendMessageW( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, SendMessageW( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
MAKEWPARAM( SB_THUMBTRACK, pwndContext->SCROLL_TrackingVal), MAKEWPARAM( SB_THUMBTRACK, pwndData->SCROLL_TrackingVal),
(LPARAM)hwndCtl ); (LPARAM)hwndCtl );
if (!pwndContext->SCROLL_MovingThumb) if (!pwndData->SCROLL_MovingThumb)
SCROLL_DrawMovingThumb(pwndContext, &context, &sbi, vertical); SCROLL_DrawMovingThumb(pwndData, &context, &sbi, vertical);
} }
} }
break; break;
case SCROLL_BOTTOM_RECT: case SCROLL_BOTTOM_RECT:
if (hittest == pwndContext->SCROLL_trackHitTest) if (hittest == pwndData->SCROLL_trackHitTest)
{ {
SCROLL_DrawInterior( &context, &sbi, sbi.xyThumbTop, vertical, pwndContext->SCROLL_trackHitTest, 0 ); SCROLL_DrawInterior( &context, &sbi, sbi.xyThumbTop, vertical, pwndData->SCROLL_trackHitTest, 0 );
if ((msg == WM_LBUTTONDOWN) || (msg == WM_SYSTIMER)) if ((msg == WM_LBUTTONDOWN) || (msg == WM_SYSTIMER))
{ {
SendMessageW( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, SendMessageW( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
@ -558,9 +558,9 @@ SCROLL_HandleScrollEvent(PWND_CONTEXT pwndContext, HWND hwnd, INT nBar, UINT msg
break; break;
case SCROLL_BOTTOM_ARROW: case SCROLL_BOTTOM_ARROW:
if (hittest == pwndContext->SCROLL_trackHitTest) if (hittest == pwndData->SCROLL_trackHitTest)
{ {
SCROLL_DrawArrows( &context, &sbi, vertical, pwndContext->SCROLL_trackHitTest, 0 ); SCROLL_DrawArrows( &context, &sbi, vertical, pwndData->SCROLL_trackHitTest, 0 );
if ((msg == WM_LBUTTONDOWN) || (msg == WM_SYSTIMER)) if ((msg == WM_LBUTTONDOWN) || (msg == WM_SYSTIMER))
{ {
SendMessageW( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, SendMessageW( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
@ -592,8 +592,8 @@ SCROLL_HandleScrollEvent(PWND_CONTEXT pwndContext, HWND hwnd, INT nBar, UINT msg
if (msg == WM_LBUTTONUP) if (msg == WM_LBUTTONUP)
{ {
hittest = pwndContext->SCROLL_trackHitTest; hittest = pwndData->SCROLL_trackHitTest;
pwndContext->SCROLL_trackHitTest = SCROLL_NOWHERE; /* Terminate tracking */ pwndData->SCROLL_trackHitTest = SCROLL_NOWHERE; /* Terminate tracking */
if (hittest == SCROLL_THUMB) if (hittest == SCROLL_THUMB)
{ {
@ -607,7 +607,7 @@ SCROLL_HandleScrollEvent(PWND_CONTEXT pwndContext, HWND hwnd, INT nBar, UINT msg
SB_ENDSCROLL, (LPARAM)hwndCtl ); SB_ENDSCROLL, (LPARAM)hwndCtl );
/* Terminate tracking */ /* Terminate tracking */
pwndContext->SCROLL_TrackingWin = 0; pwndData->SCROLL_TrackingWin = 0;
} }
ThemeCleanupDrawContext(&context); ThemeCleanupDrawContext(&context);
@ -617,13 +617,13 @@ static void
SCROLL_TrackScrollBar( HWND hwnd, INT scrollbar, POINT pt ) SCROLL_TrackScrollBar( HWND hwnd, INT scrollbar, POINT pt )
{ {
MSG msg; MSG msg;
PWND_CONTEXT pwndContext = ThemeGetWndContext(hwnd); PWND_DATA pwndData = ThemeGetWndData(hwnd);
if(!pwndContext) if(!pwndData)
return; return;
ScreenToWindow(hwnd, &pt); ScreenToWindow(hwnd, &pt);
SCROLL_HandleScrollEvent(pwndContext, hwnd, scrollbar, WM_LBUTTONDOWN, pt ); SCROLL_HandleScrollEvent(pwndData, hwnd, scrollbar, WM_LBUTTONDOWN, pt );
do do
{ {
@ -637,7 +637,7 @@ SCROLL_TrackScrollBar( HWND hwnd, INT scrollbar, POINT pt )
pt.y = GET_Y_LPARAM(msg.lParam); pt.y = GET_Y_LPARAM(msg.lParam);
ClientToScreen(hwnd, &pt); ClientToScreen(hwnd, &pt);
ScreenToWindow(hwnd, &pt); ScreenToWindow(hwnd, &pt);
SCROLL_HandleScrollEvent(pwndContext, hwnd, scrollbar, msg.message, pt ); SCROLL_HandleScrollEvent(pwndData, hwnd, scrollbar, msg.message, pt );
} }
else else
{ {

View file

@ -596,7 +596,7 @@ ThemeHandleNcMouseMove(HWND hWnd, DWORD ht, POINT* pt)
DRAW_CONTEXT context; DRAW_CONTEXT context;
TRACKMOUSEEVENT tme; TRACKMOUSEEVENT tme;
DWORD style; DWORD style;
PWND_CONTEXT pcontext; PWND_DATA pwndData;
/* First of all check if we have something to do here */ /* First of all check if we have something to do here */
style = GetWindowLongW(hWnd, GWL_STYLE); style = GetWindowLongW(hWnd, GWL_STYLE);
@ -604,8 +604,8 @@ ThemeHandleNcMouseMove(HWND hWnd, DWORD ht, POINT* pt)
return 0; return 0;
/* Get theme data for this window */ /* Get theme data for this window */
pcontext = ThemeGetWndContext(hWnd); pwndData = ThemeGetWndData(hWnd);
if (pcontext == NULL) if (pwndData == NULL)
return 0; return 0;
/* Begin tracking in the non client area if we are not tracking yet */ /* Begin tracking in the non client area if we are not tracking yet */
@ -623,24 +623,24 @@ ThemeHandleNcMouseMove(HWND hWnd, DWORD ht, POINT* pt)
ThemeInitDrawContext(&context, hWnd, 0); ThemeInitDrawContext(&context, hWnd, 0);
if (context.wi.dwStyle & WS_SYSMENU) if (context.wi.dwStyle & WS_SYSMENU)
{ {
if (HT_ISBUTTON(ht) || HT_ISBUTTON(pcontext->lastHitTest)) if (HT_ISBUTTON(ht) || HT_ISBUTTON(pwndData->lastHitTest))
ThemeDrawCaptionButtons(&context, ht, 0); ThemeDrawCaptionButtons(&context, ht, 0);
} }
if (context.wi.dwStyle & WS_HSCROLL) if (context.wi.dwStyle & WS_HSCROLL)
{ {
if (ht == HTHSCROLL || pcontext->lastHitTest == HTHSCROLL) if (ht == HTHSCROLL || pwndData->lastHitTest == HTHSCROLL)
ThemeDrawScrollBar(&context, SB_HORZ , ht == HTHSCROLL ? pt : NULL); ThemeDrawScrollBar(&context, SB_HORZ , ht == HTHSCROLL ? pt : NULL);
} }
if (context.wi.dwStyle & WS_VSCROLL) if (context.wi.dwStyle & WS_VSCROLL)
{ {
if (ht == HTVSCROLL || pcontext->lastHitTest == HTVSCROLL) if (ht == HTVSCROLL || pwndData->lastHitTest == HTVSCROLL)
ThemeDrawScrollBar(&context, SB_VERT, ht == HTVSCROLL ? pt : NULL); ThemeDrawScrollBar(&context, SB_VERT, ht == HTVSCROLL ? pt : NULL);
} }
ThemeCleanupDrawContext(&context); ThemeCleanupDrawContext(&context);
pcontext->lastHitTest = ht; pwndData->lastHitTest = ht;
return 0; return 0;
} }
@ -650,7 +650,7 @@ ThemeHandleNcMouseLeave(HWND hWnd)
{ {
DRAW_CONTEXT context; DRAW_CONTEXT context;
DWORD style; DWORD style;
PWND_CONTEXT pWndContext; PWND_DATA pwndData;
/* First of all check if we have something to do here */ /* First of all check if we have something to do here */
style = GetWindowLongW(hWnd, GWL_STYLE); style = GetWindowLongW(hWnd, GWL_STYLE);
@ -658,23 +658,23 @@ ThemeHandleNcMouseLeave(HWND hWnd)
return 0; return 0;
/* Get theme data for this window */ /* Get theme data for this window */
pWndContext = ThemeGetWndContext(hWnd); pwndData = ThemeGetWndData(hWnd);
if (pWndContext == NULL) if (pwndData == NULL)
return 0; return 0;
ThemeInitDrawContext(&context, hWnd, 0); ThemeInitDrawContext(&context, hWnd, 0);
if (context.wi.dwStyle & WS_SYSMENU && HT_ISBUTTON(pWndContext->lastHitTest)) if (context.wi.dwStyle & WS_SYSMENU && HT_ISBUTTON(pwndData->lastHitTest))
ThemeDrawCaptionButtons(&context, 0, 0); ThemeDrawCaptionButtons(&context, 0, 0);
if (context.wi.dwStyle & WS_HSCROLL && pWndContext->lastHitTest == HTHSCROLL) if (context.wi.dwStyle & WS_HSCROLL && pwndData->lastHitTest == HTHSCROLL)
ThemeDrawScrollBar(&context, SB_HORZ, NULL); ThemeDrawScrollBar(&context, SB_HORZ, NULL);
if (context.wi.dwStyle & WS_VSCROLL && pWndContext->lastHitTest == HTVSCROLL) if (context.wi.dwStyle & WS_VSCROLL && pwndData->lastHitTest == HTVSCROLL)
ThemeDrawScrollBar(&context, SB_VERT, NULL); ThemeDrawScrollBar(&context, SB_VERT, NULL);
ThemeCleanupDrawContext(&context); ThemeCleanupDrawContext(&context);
pWndContext->lastHitTest = HTNOWHERE; pwndData->lastHitTest = HTNOWHERE;
return 0; return 0;
} }
@ -687,7 +687,7 @@ ThemeHandleButton(HWND hWnd, WPARAM wParam)
WPARAM SCMsg, ht; WPARAM SCMsg, ht;
ULONG Style; ULONG Style;
DRAW_CONTEXT context; DRAW_CONTEXT context;
PWND_CONTEXT pWndContext; PWND_DATA pwndData;
Style = GetWindowLongW(hWnd, GWL_STYLE); Style = GetWindowLongW(hWnd, GWL_STYLE);
if (!((Style & WS_CAPTION) && (Style & WS_SYSMENU))) if (!((Style & WS_CAPTION) && (Style & WS_SYSMENU)))
@ -713,13 +713,13 @@ ThemeHandleButton(HWND hWnd, WPARAM wParam)
} }
/* Get theme data for this window */ /* Get theme data for this window */
pWndContext = ThemeGetWndContext(hWnd); pwndData = ThemeGetWndData(hWnd);
if (pWndContext == NULL) if (pwndData == NULL)
return; return;
ThemeInitDrawContext(&context, hWnd, 0); ThemeInitDrawContext(&context, hWnd, 0);
ThemeDrawCaptionButtons(&context, 0, wParam); ThemeDrawCaptionButtons(&context, 0, wParam);
pWndContext->lastHitTest = wParam; pwndData->lastHitTest = wParam;
SetCapture(hWnd); SetCapture(hWnd);
@ -740,11 +740,11 @@ ThemeHandleButton(HWND hWnd, WPARAM wParam)
Pressed = (ht == wParam); Pressed = (ht == wParam);
/* Only draw the buttons if the hit test changed */ /* Only draw the buttons if the hit test changed */
if (ht != pWndContext->lastHitTest && if (ht != pwndData->lastHitTest &&
(HT_ISBUTTON(ht) || HT_ISBUTTON(pWndContext->lastHitTest))) (HT_ISBUTTON(ht) || HT_ISBUTTON(pwndData->lastHitTest)))
{ {
ThemeDrawCaptionButtons(&context, 0, Pressed ? wParam: 0); ThemeDrawCaptionButtons(&context, 0, Pressed ? wParam: 0);
pWndContext->lastHitTest = ht; pwndData->lastHitTest = ht;
} }
} }

View file

@ -14,72 +14,72 @@ BYTE gabMSGPmessages[UAHOWP_MAX_SIZE];
BYTE gabDLGPmessages[UAHOWP_MAX_SIZE]; BYTE gabDLGPmessages[UAHOWP_MAX_SIZE];
BOOL gbThemeHooksActive = FALSE; BOOL gbThemeHooksActive = FALSE;
PWND_CONTEXT ThemeGetWndContext(HWND hWnd) PWND_DATA ThemeGetWndData(HWND hWnd)
{ {
PWND_CONTEXT pcontext; PWND_DATA pwndData;
pcontext = (PWND_CONTEXT)GetPropW(hWnd, (LPCWSTR)MAKEINTATOM(atWndContext)); pwndData = (PWND_DATA)GetPropW(hWnd, (LPCWSTR)MAKEINTATOM(atWndContext));
if(pcontext == NULL) if(pwndData == NULL)
{ {
pcontext = HeapAlloc(GetProcessHeap(), pwndData = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, HEAP_ZERO_MEMORY,
sizeof(WND_CONTEXT)); sizeof(WND_DATA));
if(pcontext == NULL) if(pwndData == NULL)
{ {
return NULL; return NULL;
} }
SetPropW( hWnd, (LPCWSTR)MAKEINTATOM(atWndContext), pcontext); SetPropW( hWnd, (LPCWSTR)MAKEINTATOM(atWndContext), pwndData);
} }
return pcontext; return pwndData;
} }
void ThemeDestroyWndContext(HWND hWnd) void ThemeDestroyWndData(HWND hWnd)
{ {
PWND_CONTEXT pContext; PWND_DATA pwndData;
DWORD ProcessId; DWORD ProcessId;
/*Do not destroy WND_CONTEXT of a window that belong to another process */ /*Do not destroy WND_DATA of a window that belong to another process */
GetWindowThreadProcessId(hWnd, &ProcessId); GetWindowThreadProcessId(hWnd, &ProcessId);
if(ProcessId != GetCurrentProcessId()) if(ProcessId != GetCurrentProcessId())
{ {
return; return;
} }
pContext = (PWND_CONTEXT)GetPropW(hWnd, (LPCWSTR)MAKEINTATOM(atWndContext)); pwndData = (PWND_DATA)GetPropW(hWnd, (LPCWSTR)MAKEINTATOM(atWndContext));
if(pContext == NULL) if(pwndData == NULL)
{ {
return; return;
} }
if(pContext->HasThemeRgn) if(pwndData->HasThemeRgn)
{ {
user32ApiHook.SetWindowRgn(hWnd, 0, TRUE); user32ApiHook.SetWindowRgn(hWnd, 0, TRUE);
} }
if (pContext->hTabBackgroundBrush != NULL) if (pwndData->hTabBackgroundBrush != NULL)
{ {
CloseThemeData(GetWindowTheme(hWnd)); CloseThemeData(GetWindowTheme(hWnd));
DeleteObject(pContext->hTabBackgroundBrush); DeleteObject(pwndData->hTabBackgroundBrush);
pContext->hTabBackgroundBrush = NULL; pwndData->hTabBackgroundBrush = NULL;
} }
if (pContext->hTabBackgroundBmp != NULL) if (pwndData->hTabBackgroundBmp != NULL)
{ {
DeleteObject(pContext->hTabBackgroundBmp); DeleteObject(pwndData->hTabBackgroundBmp);
pContext->hTabBackgroundBmp = NULL; pwndData->hTabBackgroundBmp = NULL;
} }
HeapFree(GetProcessHeap(), 0, pContext); HeapFree(GetProcessHeap(), 0, pwndData);
SetPropW( hWnd, (LPCWSTR)MAKEINTATOM(atWndContext), NULL); SetPropW( hWnd, (LPCWSTR)MAKEINTATOM(atWndContext), NULL);
} }
static BOOL CALLBACK ThemeCleanupChildWndContext (HWND hWnd, LPARAM msg) static BOOL CALLBACK ThemeCleanupChildWndContext (HWND hWnd, LPARAM msg)
{ {
ThemeDestroyWndContext(hWnd); ThemeDestroyWndData(hWnd);
return TRUE; return TRUE;
} }
@ -91,7 +91,7 @@ static BOOL CALLBACK ThemeCleanupWndContext(HWND hWnd, LPARAM msg)
} }
else else
{ {
ThemeDestroyWndContext(hWnd); ThemeDestroyWndData(hWnd);
EnumChildWindows (hWnd, ThemeCleanupChildWndContext, 0); EnumChildWindows (hWnd, ThemeCleanupChildWndContext, 0);
} }
@ -150,7 +150,7 @@ void SetThemeRegion(HWND hWnd)
int OnPostWinPosChanged(HWND hWnd, WINDOWPOS* pWinPos) int OnPostWinPosChanged(HWND hWnd, WINDOWPOS* pWinPos)
{ {
PWND_CONTEXT pcontext; PWND_DATA pwndData;
DWORD style; DWORD style;
/* We only proceed to change the window shape if it has a caption */ /* We only proceed to change the window shape if it has a caption */
@ -159,37 +159,37 @@ int OnPostWinPosChanged(HWND hWnd, WINDOWPOS* pWinPos)
return 0; return 0;
/* Get theme data for this window */ /* Get theme data for this window */
pcontext = ThemeGetWndContext(hWnd); pwndData = ThemeGetWndData(hWnd);
if (pcontext == NULL) if (pwndData == NULL)
return 0; return 0;
/* Do not change the region of the window if its size wasn't changed */ /* Do not change the region of the window if its size wasn't changed */
if ((pWinPos->flags & SWP_NOSIZE) != 0 && pcontext->DirtyThemeRegion == FALSE) if ((pWinPos->flags & SWP_NOSIZE) != 0 && pwndData->DirtyThemeRegion == FALSE)
return 0; return 0;
/* We don't touch the shape of the window if the application sets it on its own */ /* We don't touch the shape of the window if the application sets it on its own */
if (pcontext->HasAppDefinedRgn == TRUE) if (pwndData->HasAppDefinedRgn == TRUE)
return 0; return 0;
/* Calling SetWindowRgn will call SetWindowPos again so we need to avoid this recursion */ /* Calling SetWindowRgn will call SetWindowPos again so we need to avoid this recursion */
if (pcontext->UpdatingRgn == TRUE) if (pwndData->UpdatingRgn == TRUE)
return 0; return 0;
if(!IsAppThemed()) if(!IsAppThemed())
{ {
if(pcontext->HasThemeRgn) if(pwndData->HasThemeRgn)
{ {
pcontext->HasThemeRgn = FALSE; pwndData->HasThemeRgn = FALSE;
user32ApiHook.SetWindowRgn(hWnd, 0, TRUE); user32ApiHook.SetWindowRgn(hWnd, 0, TRUE);
} }
return 0; return 0;
} }
pcontext->DirtyThemeRegion = FALSE; pwndData->DirtyThemeRegion = FALSE;
pcontext->HasThemeRgn = TRUE; pwndData->HasThemeRgn = TRUE;
pcontext->UpdatingRgn = TRUE; pwndData->UpdatingRgn = TRUE;
SetThemeRegion(hWnd); SetThemeRegion(hWnd);
pcontext->UpdatingRgn = FALSE; pwndData->UpdatingRgn = FALSE;
return 0; return 0;
} }
@ -241,32 +241,32 @@ ThemePreWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR
{ {
case WM_THEMECHANGED: case WM_THEMECHANGED:
{ {
PWND_CONTEXT pcontext = ThemeGetWndContext(hWnd); PWND_DATA pwndData = ThemeGetWndData(hWnd);
if (GetAncestor(hWnd, GA_PARENT) == GetDesktopWindow()) if (GetAncestor(hWnd, GA_PARENT) == GetDesktopWindow())
UXTHEME_LoadTheme(TRUE); UXTHEME_LoadTheme(TRUE);
if (pcontext == NULL) if (pwndData == NULL)
return 0; return 0;
if (pcontext->hTabBackgroundBrush != NULL) if (pwndData->hTabBackgroundBrush != NULL)
{ {
DeleteObject(pcontext->hTabBackgroundBrush); DeleteObject(pwndData->hTabBackgroundBrush);
pcontext->hTabBackgroundBrush = NULL; pwndData->hTabBackgroundBrush = NULL;
} }
if (pcontext->hTabBackgroundBmp != NULL) if (pwndData->hTabBackgroundBmp != NULL)
{ {
DeleteObject(pcontext->hTabBackgroundBmp); DeleteObject(pwndData->hTabBackgroundBmp);
pcontext->hTabBackgroundBmp = NULL; pwndData->hTabBackgroundBmp = NULL;
} }
} }
case WM_NCCREATE: case WM_NCCREATE:
{ {
PWND_CONTEXT pcontext = ThemeGetWndContext(hWnd); PWND_DATA pwndData = ThemeGetWndData(hWnd);
if (pcontext == NULL) if (pwndData == NULL)
return 0; return 0;
pcontext->DirtyThemeRegion = TRUE; pwndData->DirtyThemeRegion = TRUE;
} }
} }
@ -285,7 +285,7 @@ ThemePostWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR
} }
case WM_NCDESTROY: case WM_NCDESTROY:
{ {
ThemeDestroyWndContext(hWnd); ThemeDestroyWndData(hWnd);
return 0; return 0;
} }
} }
@ -295,13 +295,13 @@ ThemePostWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR
HRESULT GetDiaogTextureBrush(HTHEME theme, HWND hwnd, HDC hdc, HBRUSH* result, BOOL changeOrigin) HRESULT GetDiaogTextureBrush(HTHEME theme, HWND hwnd, HDC hdc, HBRUSH* result, BOOL changeOrigin)
{ {
PWND_CONTEXT pcontext; PWND_DATA pwndData;
pcontext = ThemeGetWndContext(hwnd); pwndData = ThemeGetWndData(hwnd);
if (pcontext == NULL) if (pwndData == NULL)
return E_FAIL; return E_FAIL;
if (pcontext->hTabBackgroundBrush == NULL) if (pwndData->hTabBackgroundBrush == NULL)
{ {
HBITMAP hbmp; HBITMAP hbmp;
RECT dummy, bmpRect; RECT dummy, bmpRect;
@ -337,18 +337,18 @@ HRESULT GetDiaogTextureBrush(HTHEME theme, HWND hwnd, HDC hdc, HBRUSH* result, B
DeleteDC(hdcHackPattern); DeleteDC(hdcHackPattern);
/* Keep the handle of the bitmap we created so that it can be used later */ /* Keep the handle of the bitmap we created so that it can be used later */
pcontext->hTabBackgroundBmp = hbmpHack; pwndData->hTabBackgroundBmp = hbmpHack;
hbmp = hbmpHack; hbmp = hbmpHack;
} }
/* hbmp is cached so there is no need to free it */ /* hbmp is cached so there is no need to free it */
pcontext->hTabBackgroundBrush = CreatePatternBrush(hbmp); pwndData->hTabBackgroundBrush = CreatePatternBrush(hbmp);
} }
if (!pcontext->hTabBackgroundBrush) if (!pwndData->hTabBackgroundBrush)
return E_FAIL; return E_FAIL;
*result = pcontext->hTabBackgroundBrush; *result = pwndData->hTabBackgroundBrush;
return S_OK; return S_OK;
} }
@ -417,11 +417,11 @@ ThemeDlgPostWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_
int WINAPI ThemeSetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw) int WINAPI ThemeSetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw)
{ {
PWND_CONTEXT pcontext = ThemeGetWndContext(hWnd); PWND_DATA pwndData = ThemeGetWndData(hWnd);
if(pcontext) if(pwndData)
{ {
pcontext->HasAppDefinedRgn = TRUE; pwndData->HasAppDefinedRgn = TRUE;
pcontext->HasThemeRgn = FALSE; pwndData->HasThemeRgn = FALSE;
} }
return user32ApiHook.SetWindowRgn(hWnd, hRgn, bRedraw); return user32ApiHook.SetWindowRgn(hWnd, hRgn, bRedraw);
@ -429,7 +429,7 @@ int WINAPI ThemeSetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw)
BOOL WINAPI ThemeGetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi) BOOL WINAPI ThemeGetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi)
{ {
PWND_CONTEXT pwndContext; PWND_DATA pwndData;
DWORD style; DWORD style;
BOOL ret; BOOL ret;
@ -441,8 +441,8 @@ BOOL WINAPI ThemeGetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi)
if((style & (WS_HSCROLL|WS_VSCROLL))==0) if((style & (WS_HSCROLL|WS_VSCROLL))==0)
goto dodefault; goto dodefault;
pwndContext = ThemeGetWndContext(hwnd); pwndData = ThemeGetWndData(hwnd);
if (pwndContext == NULL) if (pwndData == NULL)
goto dodefault; goto dodefault;
/* /*
@ -454,10 +454,10 @@ BOOL WINAPI ThemeGetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi)
ret = user32ApiHook.GetScrollInfo(hwnd, fnBar, lpsi); ret = user32ApiHook.GetScrollInfo(hwnd, fnBar, lpsi);
if ( lpsi && if ( lpsi &&
(lpsi->fMask & SIF_TRACKPOS) && (lpsi->fMask & SIF_TRACKPOS) &&
pwndContext->SCROLL_TrackingWin == hwnd && pwndData->SCROLL_TrackingWin == hwnd &&
pwndContext->SCROLL_TrackingBar == fnBar) pwndData->SCROLL_TrackingBar == fnBar)
{ {
lpsi->nTrackPos = pwndContext->SCROLL_TrackingVal; lpsi->nTrackPos = pwndData->SCROLL_TrackingVal;
} }
return ret; return ret;

View file

@ -134,7 +134,7 @@ enum SCROLL_HITTEST
}; };
/* The window context stores data for the window needed through the life of the window */ /* The window context stores data for the window needed through the life of the window */
typedef struct _WND_CONTEXT typedef struct _WND_DATA
{ {
UINT lastHitTest; UINT lastHitTest;
BOOL HasAppDefinedRgn; BOOL HasAppDefinedRgn;
@ -151,7 +151,7 @@ typedef struct _WND_CONTEXT
INT SCROLL_TrackingBar; INT SCROLL_TrackingBar;
INT SCROLL_TrackingPos; INT SCROLL_TrackingPos;
INT SCROLL_TrackingVal; INT SCROLL_TrackingVal;
} WND_CONTEXT, *PWND_CONTEXT; } WND_DATA, *PWND_DATA;
/* The draw context stores data that are needed by the drawing operations in the non client area of the window */ /* The draw context stores data that are needed by the drawing operations in the non client area of the window */
typedef struct _DRAW_CONTEXT typedef struct _DRAW_CONTEXT
@ -228,7 +228,7 @@ void ThemeDrawScrollBar(PDRAW_CONTEXT pcontext, INT Bar, POINT* pt);
VOID NC_TrackScrollBar(HWND Wnd, WPARAM wParam, POINT Pt); VOID NC_TrackScrollBar(HWND Wnd, WPARAM wParam, POINT Pt);
void ThemeInitDrawContext(PDRAW_CONTEXT pcontext, HWND hWnd, HRGN hRgn); void ThemeInitDrawContext(PDRAW_CONTEXT pcontext, HWND hWnd, HRGN hRgn);
void ThemeCleanupDrawContext(PDRAW_CONTEXT pcontext); void ThemeCleanupDrawContext(PDRAW_CONTEXT pcontext);
PWND_CONTEXT ThemeGetWndContext(HWND hWnd); PWND_DATA ThemeGetWndData(HWND hWnd);
extern HINSTANCE hDllInst; extern HINSTANCE hDllInst;
extern ATOM atWindowTheme; extern ATOM atWindowTheme;