Some minor optimizations

svn path=/trunk/; revision=30489
This commit is contained in:
Thomas Bluemel 2007-11-15 23:57:50 +00:00
parent ef944678e3
commit 99767a3b59
3 changed files with 34 additions and 23 deletions

View file

@ -40,7 +40,7 @@ BOOL UserDrawSysMenuButton( HWND hWnd, HDC hDC, LPRECT, BOOL down );
void void
UserGetFrameSize(ULONG Style, ULONG ExStyle, SIZE *Size); UserGetFrameSize(ULONG Style, ULONG ExStyle, SIZE *Size);
void void
UserGetInsideRectNC(HWND hWnd, RECT *rect); UserGetInsideRectNC(PWINDOW Wnd, RECT *rect);
DWORD DWORD
SCROLL_HitTest( HWND hwnd, INT nBar, POINT pt, BOOL bDragging ); SCROLL_HitTest( HWND hwnd, INT nBar, POINT pt, BOOL bDragging );

View file

@ -148,18 +148,17 @@ SetSysColors(
} }
void void
UserGetInsideRectNC(HWND hWnd, RECT *rect) UserGetInsideRectNC(PWINDOW Wnd, RECT *rect)
{ {
RECT WindowRect;
ULONG Style; ULONG Style;
ULONG ExStyle; ULONG ExStyle;
Style = GetWindowLongW(hWnd, GWL_STYLE); Style = Wnd->Style;
ExStyle = GetWindowLongW(hWnd, GWL_EXSTYLE); ExStyle = Wnd->ExStyle;
GetWindowRect(hWnd, &WindowRect);
rect->top = rect->left = 0; rect->top = rect->left = 0;
rect->right = WindowRect.right - WindowRect.left; rect->right = Wnd->WindowRect.right - Wnd->WindowRect.left;
rect->bottom = WindowRect.bottom - WindowRect.top; rect->bottom = Wnd->WindowRect.bottom - Wnd->WindowRect.top;
if (Style & WS_ICONIC) if (Style & WS_ICONIC)
{ {
@ -296,21 +295,21 @@ DefWndHandleSetCursor(HWND hWnd, WPARAM wParam, LPARAM lParam, ULONG Style)
} }
static LONG static LONG
DefWndStartSizeMove(HWND hWnd, WPARAM wParam, POINT *capturePoint) DefWndStartSizeMove(HWND hWnd, PWINDOW Wnd, WPARAM wParam, POINT *capturePoint)
{ {
LONG hittest = 0; LONG hittest = 0;
POINT pt; POINT pt;
MSG msg; MSG msg;
RECT rectWindow; RECT rectWindow;
ULONG Style = GetWindowLongW(hWnd, GWL_STYLE); ULONG Style = Wnd->Style;
GetWindowRect(hWnd, &rectWindow); rectWindow = Wnd->WindowRect;
if ((wParam & 0xfff0) == SC_MOVE) if ((wParam & 0xfff0) == SC_MOVE)
{ {
/* Move pointer at the center of the caption */ /* Move pointer at the center of the caption */
RECT rect; RECT rect;
UserGetInsideRectNC(hWnd, &rect); UserGetInsideRectNC(Wnd, &rect);
if (Style & WS_SYSMENU) if (Style & WS_SYSMENU)
rect.left += GetSystemMetrics(SM_CXSIZE) + 1; rect.left += GetSystemMetrics(SM_CXSIZE) + 1;
if (Style & WS_MINIMIZEBOX) if (Style & WS_MINIMIZEBOX)
@ -436,14 +435,22 @@ DefWndDoSizeMove(HWND hwnd, WORD wParam)
HCURSOR hDragCursor = 0, hOldCursor = 0; HCURSOR hDragCursor = 0, hOldCursor = 0;
POINT minTrack, maxTrack; POINT minTrack, maxTrack;
POINT capturePoint, pt; POINT capturePoint, pt;
ULONG Style = GetWindowLongW(hwnd, GWL_STYLE); ULONG Style, ExStyle;
ULONG ExStyle = GetWindowLongW(hwnd, GWL_EXSTYLE);
BOOL thickframe; BOOL thickframe;
BOOL iconic = Style & WS_MINIMIZE; BOOL iconic;
BOOL moved = FALSE; BOOL moved = FALSE;
DWORD dwPoint = GetMessagePos(); DWORD dwPoint = GetMessagePos();
BOOL DragFullWindows = FALSE; BOOL DragFullWindows = FALSE;
HWND hWndParent = NULL; HWND hWndParent = NULL;
PWINDOW Wnd;
Wnd = ValidateHwnd(hwnd);
if (!Wnd)
return;
Style = Wnd->Style;
ExStyle = Wnd->ExStyle;
iconic = (Style & WS_MINIMIZE) != 0;
SystemParametersInfoA(SPI_GETDRAGFULLWINDOWS, 0, &DragFullWindows, 0); SystemParametersInfoA(SPI_GETDRAGFULLWINDOWS, 0, &DragFullWindows, 0);
@ -451,7 +458,7 @@ DefWndDoSizeMove(HWND hwnd, WORD wParam)
pt.y = GET_Y_LPARAM(dwPoint); pt.y = GET_Y_LPARAM(dwPoint);
capturePoint = pt; capturePoint = pt;
if (IsZoomed(hwnd) || !IsWindowVisible(hwnd)) if ((Style & WS_MAXIMIZE) || !IsWindowVisible(hwnd))
{ {
return; return;
} }
@ -461,7 +468,7 @@ DefWndDoSizeMove(HWND hwnd, WORD wParam)
{ {
if (!hittest) if (!hittest)
{ {
hittest = DefWndStartSizeMove(hwnd, wParam, &capturePoint); hittest = DefWndStartSizeMove(hwnd, Wnd, wParam, &capturePoint);
} }
if (!hittest) if (!hittest)
{ {
@ -481,7 +488,7 @@ DefWndDoSizeMove(HWND hwnd, WORD wParam)
else else
{ {
SetCapture(hwnd); SetCapture(hwnd);
hittest = DefWndStartSizeMove(hwnd, wParam, &capturePoint); hittest = DefWndStartSizeMove(hwnd, Wnd, wParam, &capturePoint);
if (!hittest) if (!hittest)
{ {
ReleaseCapture(); ReleaseCapture();
@ -493,7 +500,7 @@ DefWndDoSizeMove(HWND hwnd, WORD wParam)
/* Get min/max info */ /* Get min/max info */
WinPosGetMinMaxInfo(hwnd, NULL, NULL, &minTrack, &maxTrack); WinPosGetMinMaxInfo(hwnd, NULL, NULL, &minTrack, &maxTrack);
GetWindowRect(hwnd, &sizingRect); sizingRect = Wnd->WindowRect;
if (Style & WS_CHILD) if (Style & WS_CHILD)
{ {
hWndParent = GetParent(hwnd); hWndParent = GetParent(hwnd);

View file

@ -514,20 +514,24 @@ got_bitmap:
* Draw a single menu item. * Draw a single menu item.
*/ */
static void FASTCALL static void FASTCALL
MenuDrawMenuItem(HWND Wnd, PROSMENUINFO MenuInfo, HWND WndOwner, HDC Dc, MenuDrawMenuItem(HWND hWnd, PROSMENUINFO MenuInfo, HWND WndOwner, HDC Dc,
PROSMENUITEMINFO Item, UINT Height, BOOL MenuBar, UINT Action) PROSMENUITEMINFO Item, UINT Height, BOOL MenuBar, UINT Action)
{ {
RECT Rect; RECT Rect;
PWCHAR Text; PWCHAR Text;
BOOL flat_menu = FALSE; BOOL flat_menu = FALSE;
int bkgnd; int bkgnd;
PWINDOW Wnd = ValidateHwnd(hWnd);
if (!Wnd)
return;
if (0 != (Item->fType & MF_SYSMENU)) if (0 != (Item->fType & MF_SYSMENU))
{ {
if (! IsIconic(Wnd)) if ( (Wnd->Style & WS_MINIMIZE))
{ {
UserGetInsideRectNC(Wnd, &Rect); UserGetInsideRectNC(Wnd, &Rect);
UserDrawSysMenuButton(Wnd, Dc, &Rect, UserDrawSysMenuButton(hWnd, Dc, &Rect,
Item->fState & (MF_HILITE | MF_MOUSESELECT)); Item->fState & (MF_HILITE | MF_MOUSESELECT));
} }
return; return;
@ -608,7 +612,7 @@ MenuDrawMenuItem(HWND Wnd, PROSMENUINFO MenuInfo, HWND WndOwner, HDC Dc,
dis.hDC = Dc; dis.hDC = Dc;
dis.rcItem = Rect; dis.rcItem = Rect;
TRACE("Ownerdraw: owner=%p itemID=%d, itemState=%d, itemAction=%d, " TRACE("Ownerdraw: owner=%p itemID=%d, itemState=%d, itemAction=%d, "
"hwndItem=%p, hdc=%p, rcItem={%ld,%ld,%ld,%ld}\n", Wnd, "hwndItem=%p, hdc=%p, rcItem={%ld,%ld,%ld,%ld}\n", hWnd,
dis.itemID, dis.itemState, dis.itemAction, dis.hwndItem, dis.itemID, dis.itemState, dis.itemAction, dis.hwndItem,
dis.hDC, dis.rcItem.left, dis.rcItem.top, dis.rcItem.right, dis.hDC, dis.rcItem.left, dis.rcItem.top, dis.rcItem.right,
dis.rcItem.bottom); dis.rcItem.bottom);