mirror of
https://github.com/reactos/reactos.git
synced 2024-07-12 23:55:07 +00:00
fixed GDI handle leaks
svn path=/trunk/; revision=5790
This commit is contained in:
parent
43fa5d1ab2
commit
594afa2f55
|
@ -197,9 +197,8 @@ LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
{
|
||||
switch(nmsg) {
|
||||
case WM_PAINT: {
|
||||
PAINTSTRUCT ps;
|
||||
draw_desktop_background(_hwnd, BeginPaint(_hwnd, &ps));
|
||||
EndPaint(_hwnd, &ps);
|
||||
PaintCanvas canvas(_hwnd);
|
||||
draw_desktop_background(_hwnd, canvas);
|
||||
break;}
|
||||
|
||||
case WM_LBUTTONDBLCLK:
|
||||
|
|
|
@ -64,10 +64,15 @@ DesktopBar::DesktopBar(HWND hwnd)
|
|||
: super(hwnd),
|
||||
WM_TASKBARCREATED(RegisterWindowMessage(WINMSG_TASKBARCREATED))
|
||||
{
|
||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &_work_area_org, 0);
|
||||
}
|
||||
|
||||
DesktopBar::~DesktopBar()
|
||||
{
|
||||
// restore work area to the previous size
|
||||
SystemParametersInfo(SPI_SETWORKAREA, 0, &_work_area_org, 0);
|
||||
PostMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETWORKAREA, 0);
|
||||
|
||||
// exit application after destroying desktop window
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
|
@ -166,7 +171,7 @@ LRESULT DesktopBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
|
||||
WindowRect rect(_hwnd);
|
||||
RECT work_area = {0, 0, GetSystemMetrics(SM_CXSCREEN), rect.top};
|
||||
SystemParametersInfo(SPI_SETWORKAREA, 0, &work_area, 0);
|
||||
SystemParametersInfo(SPI_SETWORKAREA, 0, &work_area, 0); // don't use SPIF_SENDCHANGE because then we have to wait for any message being delivered
|
||||
PostMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETWORKAREA, 0);
|
||||
break;}
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ struct DesktopBar : public OwnerDrawParent<Window>
|
|||
|
||||
protected:
|
||||
int WM_TASKBARCREATED;
|
||||
RECT _work_area_org;
|
||||
|
||||
LRESULT Init(LPCREATESTRUCT pcs);
|
||||
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
|
||||
|
|
|
@ -220,7 +220,7 @@ void NotifyArea::Refresh()
|
|||
|
||||
void NotifyArea::Paint()
|
||||
{
|
||||
BufferedPaintCanvas canvas(_hwnd);
|
||||
PaintCanvas canvas(_hwnd);
|
||||
|
||||
// first fill with the background color
|
||||
FillRect(canvas, &canvas.rcPaint, GetSysColorBrush(COLOR_BTNFACE));
|
||||
|
@ -324,7 +324,7 @@ bool ClockWindow::FormatTime()
|
|||
|
||||
if (_tcscmp(buffer, _time)) {
|
||||
_tcscpy(_time, buffer);
|
||||
return true;
|
||||
return true; // The text to display has changed.
|
||||
}
|
||||
|
||||
return false; // no change
|
||||
|
@ -335,7 +335,7 @@ void ClockWindow::Paint()
|
|||
PaintCanvas canvas(_hwnd);
|
||||
|
||||
BkMode bkmode(canvas, TRANSPARENT);
|
||||
SelectedFont font(canvas, GetStockFont(ANSI_VAR_FONT));
|
||||
FontSelection font(canvas, GetStockFont(ANSI_VAR_FONT));
|
||||
|
||||
DrawText(canvas, _time, -1, ClientRect(_hwnd), DT_SINGLELINE|DT_VCENTER|DT_NOPREFIX);
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ struct PaintCanvas : public PAINTSTRUCT
|
|||
BeginPaint(hwnd, this);
|
||||
}
|
||||
|
||||
PaintCanvas()
|
||||
~PaintCanvas()
|
||||
{
|
||||
EndPaint(_hwnd, this);
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ struct SelectedBitmap
|
|||
SelectedBitmap(HDC hdc, HBITMAP hbmp)
|
||||
: _hdc(hdc), _old_hbmp(SelectBitmap(hdc, hbmp)) {}
|
||||
|
||||
~SelectedBitmap() {SelectBitmap(_hdc, _old_hbmp);}
|
||||
~SelectedBitmap() {DeleteObject(SelectBitmap(_hdc, _old_hbmp));}
|
||||
|
||||
protected:
|
||||
HDC _hdc;
|
||||
|
@ -253,7 +253,10 @@ struct BufferedCanvas : public BufferCanvas
|
|||
struct BufferedPaintCanvas : public PaintCanvas, public BufferedCanvas
|
||||
{
|
||||
BufferedPaintCanvas(HWND hwnd)
|
||||
: PaintCanvas(hwnd), BufferedCanvas(hdc, 0, 0, rcPaint.right, rcPaint.bottom) {}
|
||||
: PaintCanvas(hwnd),
|
||||
BufferedCanvas(PAINTSTRUCT::hdc, 0, 0, rcPaint.right, rcPaint.bottom)
|
||||
{
|
||||
}
|
||||
|
||||
operator HDC() {return BufferedCanvas::_hdc;}
|
||||
};
|
||||
|
@ -283,12 +286,12 @@ protected:
|
|||
COLORREF _old_bkmode;
|
||||
};
|
||||
|
||||
struct SelectedFont
|
||||
struct FontSelection
|
||||
{
|
||||
SelectedFont(HDC hdc, HFONT hFont)
|
||||
FontSelection(HDC hdc, HFONT hFont)
|
||||
: _hdc(hdc), _old_hFont(SelectFont(hdc, hFont)) {}
|
||||
|
||||
~SelectedFont() {SelectFont(_hdc, _old_hFont);}
|
||||
~FontSelection() {SelectFont(_hdc, _old_hFont);}
|
||||
|
||||
protected:
|
||||
HDC _hdc;
|
||||
|
|
|
@ -264,16 +264,13 @@ LRESULT ChildWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
{
|
||||
switch(nmsg) {
|
||||
case WM_PAINT: {
|
||||
PAINTSTRUCT ps;
|
||||
HBRUSH lastBrush;
|
||||
PaintCanvas canvas(_hwnd);
|
||||
ClientRect rt(_hwnd);
|
||||
BeginPaint(_hwnd, &ps);
|
||||
rt.left = _split_pos-SPLIT_WIDTH/2;
|
||||
rt.right = _split_pos+SPLIT_WIDTH/2+1;
|
||||
lastBrush = SelectBrush(ps.hdc, GetStockBrush(COLOR_SPLITBAR));
|
||||
Rectangle(ps.hdc, rt.left, rt.top-1, rt.right, rt.bottom+1);
|
||||
SelectObject(ps.hdc, lastBrush);
|
||||
EndPaint(_hwnd, &ps);
|
||||
HBRUSH lastBrush = SelectBrush(canvas, GetStockBrush(COLOR_SPLITBAR));
|
||||
Rectangle(canvas, rt.left, rt.top-1, rt.right, rt.bottom+1);
|
||||
SelectObject(canvas, lastBrush);
|
||||
break;}
|
||||
|
||||
case WM_SETCURSOR:
|
||||
|
|
Loading…
Reference in a new issue