Fix DC leak

svn path=/trunk/; revision=6798
This commit is contained in:
Gé van Geldorp 2003-11-25 23:47:10 +00:00
parent 12903da5d6
commit d1dcdd7a8d

View file

@ -790,6 +790,7 @@ DefWndDoButton(HWND hWnd, WPARAM wParam)
BOOL InBtn, HasBtn = FALSE; BOOL InBtn, HasBtn = FALSE;
ULONG Btn, Style; ULONG Btn, Style;
WPARAM SCMsg, CurBtn = wParam, OrigBtn = wParam; WPARAM SCMsg, CurBtn = wParam, OrigBtn = wParam;
HDC WindowDC;
Style = GetWindowLongW(hWnd, GWL_STYLE); Style = GetWindowLongW(hWnd, GWL_STYLE);
switch(wParam) switch(wParam)
@ -818,7 +819,10 @@ DefWndDoButton(HWND hWnd, WPARAM wParam)
SetCapture(hWnd); SetCapture(hWnd);
if(HasBtn) if(HasBtn)
UserDrawCaptionButtonWnd( hWnd, GetWindowDC(hWnd), HasBtn , Btn); {
WindowDC = GetWindowDC(hWnd);
UserDrawCaptionButtonWnd(hWnd, WindowDC, HasBtn , Btn);
}
while(1) while(1)
{ {
@ -832,6 +836,8 @@ DefWndDoButton(HWND hWnd, WPARAM wParam)
else else
{ {
ReleaseCapture(); ReleaseCapture();
if (HasBtn)
ReleaseDC(hWnd, WindowDC);
return; return;
} }
case WM_NCMOUSEMOVE: case WM_NCMOUSEMOVE:
@ -841,7 +847,7 @@ DefWndDoButton(HWND hWnd, WPARAM wParam)
CurBtn = DefWndNCHitTest(hWnd, Msg.pt); CurBtn = DefWndNCHitTest(hWnd, Msg.pt);
if(InBtn != (CurBtn == OrigBtn)) if(InBtn != (CurBtn == OrigBtn))
{ {
UserDrawCaptionButtonWnd( hWnd, GetWindowDC(hWnd), (CurBtn == OrigBtn) , Btn); UserDrawCaptionButtonWnd( hWnd, WindowDC, (CurBtn == OrigBtn) , Btn);
} }
InBtn = CurBtn == OrigBtn; InBtn = CurBtn == OrigBtn;
} }
@ -850,7 +856,8 @@ DefWndDoButton(HWND hWnd, WPARAM wParam)
} }
done: done:
UserDrawCaptionButtonWnd( hWnd, GetWindowDC(hWnd), FALSE , Btn); UserDrawCaptionButtonWnd( hWnd, WindowDC, FALSE , Btn);
ReleaseDC(hWnd, WindowDC);
ReleaseCapture(); ReleaseCapture();
SendMessageA(hWnd, WM_SYSCOMMAND, SCMsg, 0); SendMessageA(hWnd, WM_SYSCOMMAND, SCMsg, 0);
return; return;