mirror of
https://github.com/reactos/reactos.git
synced 2024-09-09 20:30:04 +00:00
fixed more memory and GDI handle leaks
svn path=/trunk/; revision=5791
This commit is contained in:
parent
594afa2f55
commit
b457e5103c
|
@ -841,28 +841,22 @@ int Pane::Notify(int id, NMHDR* pnmh)
|
||||||
|
|
||||||
OutputWorker::OutputWorker()
|
OutputWorker::OutputWorker()
|
||||||
{
|
{
|
||||||
HDC hdc = GetDC(0);
|
_hfont = CreateFont(-MulDiv(8,GetDeviceCaps(WindowCanvas(0),LOGPIXELSY),72), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TEXT("MS Sans Serif"));
|
||||||
|
|
||||||
_hfont = CreateFont(-MulDiv(8,GetDeviceCaps(hdc,LOGPIXELSY),72), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TEXT("MS Sans Serif"));
|
|
||||||
|
|
||||||
ReleaseDC(0, hdc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputWorker::init_output(HWND hwnd)
|
void OutputWorker::init_output(HWND hwnd)
|
||||||
{
|
{
|
||||||
TCHAR b[16];
|
TCHAR b[16];
|
||||||
HFONT old_font;
|
|
||||||
HDC hdc = GetDC(hwnd);
|
WindowCanvas canvas(hwnd);
|
||||||
|
|
||||||
if (GetNumberFormat(LOCALE_USER_DEFAULT, 0, TEXT("1000"), 0, b, 16) > 4)
|
if (GetNumberFormat(LOCALE_USER_DEFAULT, 0, TEXT("1000"), 0, b, 16) > 4)
|
||||||
_num_sep = b[1];
|
_num_sep = b[1];
|
||||||
else
|
else
|
||||||
_num_sep = TEXT('.');
|
_num_sep = TEXT('.');
|
||||||
|
|
||||||
old_font = SelectFont(hdc, _hfont);
|
FontSelection font(canvas, _hfont);
|
||||||
GetTextExtentPoint32(hdc, TEXT(" "), 1, &_spaceSize);
|
GetTextExtentPoint32(canvas, TEXT(" "), 1, &_spaceSize);
|
||||||
SelectFont(hdc, old_font);
|
|
||||||
ReleaseDC(hwnd, hdc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ void QuickLaunchBar::AddShortcuts()
|
||||||
_dir->smart_scan();
|
_dir->smart_scan();
|
||||||
|
|
||||||
ShellFolder desktop_folder;
|
ShellFolder desktop_folder;
|
||||||
HDC hdc_wnd = GetDC(_hwnd);
|
WindowCanvas canvas(_hwnd);
|
||||||
|
|
||||||
TBBUTTON btn = {-2/*I_IMAGENONE*/, 0, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0};
|
TBBUTTON btn = {-2/*I_IMAGENONE*/, 0, TBSTATE_ENABLED, BTNS_BUTTON, {0, 0}, 0, 0};
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ void QuickLaunchBar::AddShortcuts()
|
||||||
ShellEntry* shell_entry = static_cast<ShellEntry*>(entry);
|
ShellEntry* shell_entry = static_cast<ShellEntry*>(entry);
|
||||||
|
|
||||||
const String& entry_name = desktop_folder.get_name(shell_entry->_pidl);
|
const String& entry_name = desktop_folder.get_name(shell_entry->_pidl);
|
||||||
HBITMAP hbmp = create_bitmap_from_icon(shell_entry->_hIcon, GetSysColorBrush(COLOR_BTNFACE), hdc_wnd);
|
HBITMAP hbmp = create_bitmap_from_icon(shell_entry->_hIcon, GetSysColorBrush(COLOR_BTNFACE), canvas);
|
||||||
|
|
||||||
TBADDBITMAP ab = {0, (UINT_PTR)hbmp};
|
TBADDBITMAP ab = {0, (UINT_PTR)hbmp};
|
||||||
int bmp_idx = SendMessage(_hwnd, TB_ADDBITMAP, 1, (LPARAM)&ab);
|
int bmp_idx = SendMessage(_hwnd, TB_ADDBITMAP, 1, (LPARAM)&ab);
|
||||||
|
@ -132,8 +132,6 @@ void QuickLaunchBar::AddShortcuts()
|
||||||
SendMessage(_hwnd, TB_INSERTBUTTON, idx, (LPARAM)&btn);
|
SendMessage(_hwnd, TB_INSERTBUTTON, idx, (LPARAM)&btn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReleaseDC(_hwnd, hdc_wnd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT QuickLaunchBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
LRESULT QuickLaunchBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
||||||
|
|
|
@ -304,7 +304,7 @@ void StartMenu::AddButton(LPCTSTR title, HICON hIcon, bool hasSubmenu, UINT id,
|
||||||
}
|
}
|
||||||
|
|
||||||
// widen window, if it is too small
|
// widen window, if it is too small
|
||||||
int width = StartMenuButton::GetTextWidth(title) + 16/*icon*/ + 10/*placeholder*/ + 16/*arrow*/;
|
int width = StartMenuButton::GetTextWidth(title,_hwnd) + 16/*icon*/ + 10/*placeholder*/ + 16/*arrow*/;
|
||||||
|
|
||||||
ClientRect clnt(_hwnd);
|
ClientRect clnt(_hwnd);
|
||||||
if (width > clnt.right)
|
if (width > clnt.right)
|
||||||
|
@ -436,15 +436,13 @@ void StartMenu::CloseStartMenu(int id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int StartMenuButton::GetTextWidth(LPCTSTR title)
|
int StartMenuButton::GetTextWidth(LPCTSTR title, HWND hwnd)
|
||||||
{
|
{
|
||||||
HDC hdc = GetDC(0);
|
WindowCanvas canvas(hwnd);
|
||||||
FontSelection font(hdc, GetStockFont(DEFAULT_GUI_FONT));
|
FontSelection font(canvas, GetStockFont(DEFAULT_GUI_FONT));
|
||||||
|
|
||||||
RECT rect = {0, 0, 0, 0};
|
RECT rect = {0, 0, 0, 0};
|
||||||
DrawText(hdc, title, -1, &rect, DT_SINGLELINE|DT_NOPREFIX|DT_CALCRECT);
|
DrawText(canvas, title, -1, &rect, DT_SINGLELINE|DT_NOPREFIX|DT_CALCRECT);
|
||||||
|
|
||||||
ReleaseDC(0, hdc);
|
|
||||||
|
|
||||||
return rect.right-rect.left;
|
return rect.right-rect.left;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,14 @@
|
||||||
struct StartMenuDirectory
|
struct StartMenuDirectory
|
||||||
{
|
{
|
||||||
StartMenuDirectory(const ShellDirectory& dir, bool subfolders=true)
|
StartMenuDirectory(const ShellDirectory& dir, bool subfolders=true)
|
||||||
: _dir(dir), _subfolders(subfolders) {}
|
: _dir(dir), _subfolders(subfolders)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~StartMenuDirectory()
|
||||||
|
{
|
||||||
|
_dir.free_subentries();
|
||||||
|
}
|
||||||
|
|
||||||
ShellDirectory _dir;
|
ShellDirectory _dir;
|
||||||
bool _subfolders;
|
bool _subfolders;
|
||||||
|
@ -72,7 +79,7 @@ struct StartMenuButton : public OwnerdrawnButton
|
||||||
StartMenuButton(HWND hwnd, HICON hIcon, bool hasSubmenu)
|
StartMenuButton(HWND hwnd, HICON hIcon, bool hasSubmenu)
|
||||||
: super(hwnd), _hIcon(hIcon), _hasSubmenu(hasSubmenu) {}
|
: super(hwnd), _hIcon(hIcon), _hasSubmenu(hasSubmenu) {}
|
||||||
|
|
||||||
static int GetTextWidth(LPCTSTR title);
|
static int GetTextWidth(LPCTSTR title, HWND hwnd);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
|
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
|
||||||
|
|
|
@ -236,9 +236,7 @@ BOOL CALLBACK TaskBar::EnumWndProc(HWND hwnd, LPARAM lparam)
|
||||||
found->second._id = pThis->_next_id++;
|
found->second._id = pThis->_next_id++;
|
||||||
} else {
|
} else {
|
||||||
HICON hIcon = get_window_icon(hwnd);
|
HICON hIcon = get_window_icon(hwnd);
|
||||||
HDC hdc_wnd = GetDC(pThis->_htoolbar);
|
HBITMAP hbmp = create_bitmap_from_icon(hIcon, GetSysColorBrush(COLOR_BTNFACE), WindowCanvas(pThis->_htoolbar));
|
||||||
HBITMAP hbmp = create_bitmap_from_icon(hIcon, GetSysColorBrush(COLOR_BTNFACE), hdc_wnd);
|
|
||||||
ReleaseDC(pThis->_htoolbar, hdc_wnd);
|
|
||||||
|
|
||||||
TBADDBITMAP ab = {0, (UINT_PTR)hbmp};
|
TBADDBITMAP ab = {0, (UINT_PTR)hbmp};
|
||||||
int bmp_idx = SendMessage(pThis->_htoolbar, TB_ADDBITMAP, 1, (LPARAM)&ab);
|
int bmp_idx = SendMessage(pThis->_htoolbar, TB_ADDBITMAP, 1, (LPARAM)&ab);
|
||||||
|
|
|
@ -186,9 +186,6 @@ protected:
|
||||||
HWND _hwnd;
|
HWND _hwnd;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// double buffering classes
|
|
||||||
|
|
||||||
struct Canvas
|
struct Canvas
|
||||||
{
|
{
|
||||||
Canvas(HDC hdc) : _hdc(hdc) {}
|
Canvas(HDC hdc) : _hdc(hdc) {}
|
||||||
|
@ -199,6 +196,20 @@ protected:
|
||||||
HDC _hdc;
|
HDC _hdc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct WindowCanvas : public Canvas
|
||||||
|
{
|
||||||
|
WindowCanvas(HWND hwnd)
|
||||||
|
: Canvas(GetDC(hwnd)), _hwnd(hwnd) {}
|
||||||
|
|
||||||
|
~WindowCanvas() {ReleaseDC(_hwnd, _hdc);}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
HWND _hwnd;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// double buffering classes
|
||||||
|
|
||||||
struct MemCanvas : public Canvas
|
struct MemCanvas : public Canvas
|
||||||
{
|
{
|
||||||
MemCanvas(HDC hdc=0)
|
MemCanvas(HDC hdc=0)
|
||||||
|
|
Loading…
Reference in a new issue