user32: Pass the window styles to NC_GetInsideRect instead of accessing the window structure.

This commit is contained in:
Alexandre Julliard 2010-09-07 14:33:13 +02:00
parent 7295b6746d
commit c5bf4976f1
1 changed files with 30 additions and 24 deletions

View File

@ -479,7 +479,7 @@ LRESULT NC_HandleNCCalcSize( HWND hwnd, RECT *winRect )
* but without the borders (if any).
* The rectangle is in window coordinates (for drawing with GetWindowDC()).
*/
static void NC_GetInsideRect( HWND hwnd, RECT *rect )
static void NC_GetInsideRect( HWND hwnd, RECT *rect, DWORD style, DWORD ex_style )
{
WND *wndPtr = WIN_GetPtr( hwnd );
@ -489,30 +489,29 @@ static void NC_GetInsideRect( HWND hwnd, RECT *rect )
rect->right = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
rect->bottom = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
if (wndPtr->dwStyle & WS_ICONIC) goto END;
if (style & WS_ICONIC) goto END;
/* Remove frame from rectangle */
if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
if (HAS_THICKFRAME( style, ex_style ))
{
InflateRect( rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
}
else if (HAS_DLGFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
else if (HAS_DLGFRAME( style, ex_style ))
{
InflateRect( rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
}
else if (HAS_THINFRAME( wndPtr->dwStyle ))
else if (HAS_THINFRAME( style ))
{
InflateRect( rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER) );
}
/* We have additional border information if the window
* is a child (but not an MDI child) */
if ( (wndPtr->dwStyle & WS_CHILD) &&
( (wndPtr->dwExStyle & WS_EX_MDICHILD) == 0 ) )
if ((style & WS_CHILD) && !(ex_style & WS_EX_MDICHILD))
{
if (wndPtr->dwExStyle & WS_EX_CLIENTEDGE)
if (ex_style & WS_EX_CLIENTEDGE)
InflateRect (rect, -GetSystemMetrics(SM_CXEDGE), -GetSystemMetrics(SM_CYEDGE));
if (wndPtr->dwExStyle & WS_EX_STATICEDGE)
if (ex_style & WS_EX_STATICEDGE)
InflateRect (rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
}
@ -706,7 +705,10 @@ BOOL NC_DrawSysButton (HWND hwnd, HDC hdc, BOOL down)
if (hIcon)
{
RECT rect;
NC_GetInsideRect( hwnd, &rect );
DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
DWORD ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
NC_GetInsideRect( hwnd, &rect, style, ex_style );
DrawIconEx (hdc, rect.left + 2, rect.top + 1, hIcon,
GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);
@ -728,11 +730,13 @@ BOOL NC_DrawSysButton (HWND hwnd, HDC hdc, BOOL down)
static void NC_DrawCloseButton (HWND hwnd, HDC hdc, BOOL down, BOOL bGrayed)
{
RECT rect;
DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
DWORD ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
NC_GetInsideRect( hwnd, &rect );
NC_GetInsideRect( hwnd, &rect, style, ex_style );
/* A tool window has a smaller Close button */
if (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_TOOLWINDOW)
if (ex_style & WS_EX_TOOLWINDOW)
{
INT iBmpHeight = 11; /* Windows does not use SM_CXSMSIZE and SM_CYSMSIZE */
INT iBmpWidth = 11; /* it uses 11x11 for the close button in tool window */
@ -766,15 +770,16 @@ static void NC_DrawMaxButton(HWND hwnd,HDC hdc,BOOL down, BOOL bGrayed)
{
RECT rect;
UINT flags;
DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
DWORD ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
/* never draw maximize box when window has WS_EX_TOOLWINDOW style */
if (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_TOOLWINDOW)
return;
if (ex_style & WS_EX_TOOLWINDOW) return;
flags = IsZoomed(hwnd) ? DFCS_CAPTIONRESTORE : DFCS_CAPTIONMAX;
flags = (style & WS_MAXIMIZE) ? DFCS_CAPTIONRESTORE : DFCS_CAPTIONMAX;
NC_GetInsideRect( hwnd, &rect );
if (GetWindowLongW( hwnd, GWL_STYLE) & WS_SYSMENU)
NC_GetInsideRect( hwnd, &rect, style, ex_style );
if (style & WS_SYSMENU)
rect.right -= GetSystemMetrics(SM_CXSIZE);
rect.left = rect.right - GetSystemMetrics(SM_CXSIZE);
rect.bottom = rect.top + GetSystemMetrics(SM_CYSIZE) - 2;
@ -796,12 +801,12 @@ static void NC_DrawMinButton(HWND hwnd,HDC hdc,BOOL down, BOOL bGrayed)
RECT rect;
UINT flags = DFCS_CAPTIONMIN;
DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
DWORD ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
/* never draw minimize box when window has WS_EX_TOOLWINDOW style */
if (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_TOOLWINDOW)
return;
if (ex_style & WS_EX_TOOLWINDOW) return;
NC_GetInsideRect( hwnd, &rect );
NC_GetInsideRect( hwnd, &rect, style, ex_style );
if (style & WS_SYSMENU)
rect.right -= GetSystemMetrics(SM_CXSIZE);
if (style & (WS_MAXIMIZEBOX|WS_MINIMIZEBOX))
@ -1215,13 +1220,14 @@ void NC_GetSysPopupPos( HWND hwnd, RECT* rect )
if (IsIconic(hwnd)) GetWindowRect( hwnd, rect );
else
{
DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
DWORD ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
WND *wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return;
NC_GetInsideRect( hwnd, rect );
NC_GetInsideRect( hwnd, rect, style, ex_style );
OffsetRect( rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top);
if (wndPtr->dwStyle & WS_CHILD)
ClientToScreen( GetParent(hwnd), (POINT *)rect );
if (style & WS_CHILD) ClientToScreen( GetParent(hwnd), (POINT *)rect );
rect->right = rect->left + GetSystemMetrics(SM_CYCAPTION) - 1;
rect->bottom = rect->top + GetSystemMetrics(SM_CYCAPTION) - 1;
WIN_ReleasePtr( wndPtr );
@ -1643,7 +1649,7 @@ BOOL WINAPI GetTitleBarInfo(HWND hwnd, PTITLEBARINFO tbi) {
}
dwStyle = GetWindowLongW(hwnd, GWL_STYLE);
dwExStyle = GetWindowLongW(hwnd, GWL_EXSTYLE);
NC_GetInsideRect(hwnd, &tbi->rcTitleBar);
NC_GetInsideRect(hwnd, &tbi->rcTitleBar, dwStyle, dwExStyle);
GetWindowRect(hwnd, &wndRect);