Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

CBrush DeleteObject Problem

volkansenvolkansen Member Posts: 1
Hi,

I am creating and deleting MFC gdi objects and watching the number of GDI Objects that application uses via Windows Task Manager.

When i create a CBrush object by CreateSolidBrush i observe an increment in GDI Object count of application. However when i delete the brush by DeleteObject there happens no change.

I am using VS 2003, i create an MFC Dialog Application, add two buttons and two handlers for them. And a CBrush* member.

Here is the functions that handles button clicks:


// m_pBrush is a member CBrush*
void CBrushSampleDlg::OnBnClickedButtonCreate()
{
m_pBrush = new CBrush;
m_pBrush->CreateSolidBrush(RGB(155,0,0));
}

void CBrushSampleDlg::OnBnClickedButtonDelete()
{
m_pBrush->DeleteObject();
delete m_pBrush;
}

Does anybody have an idea why GDI object count does not decrement when i delete the brush i have created?

Thanks in advance.

Volkan

Comments

  • FebilFebil Member Posts: 1
    Hai
    I am also facing the same problem in the case of CBrush GDI count. I also Noticed that if we create n brushes and then delete n brushes after that. It will not decrement its count. If we create n brushes , the GDI count will be n not 2n.
    If you have noticed any solving methods, plz respond to me.
    Thanks
    Febil Chacko
    febil.chacko@nestgroup.net

    Hi,
    :
    : I am creating and deleting MFC gdi objects and watching the number
    : of GDI Objects that application uses via Windows Task Manager.
    :
    : When i create a CBrush object by CreateSolidBrush i observe an
    : increment in GDI Object count of application. However when i delete
    : the brush by DeleteObject there happens no change.
    :
    : I am using VS 2003, i create an MFC Dialog Application, add two
    : buttons and two handlers for them. And a CBrush* member.
    :
    : Here is the functions that handles button clicks:
    :
    :
    : // m_pBrush is a member CBrush*
    : void CBrushSampleDlg::OnBnClickedButtonCreate()
    : {
    : m_pBrush = new CBrush;
    : m_pBrush->CreateSolidBrush(RGB(155,0,0));
    : }
    :
    : void CBrushSampleDlg::OnBnClickedButtonDelete()
    : {
    : m_pBrush->DeleteObject();
    : delete m_pBrush;
    : }
    :
    : Does anybody have an idea why GDI object count does not decrement
    : when i delete the brush i have created?
    :
    : Thanks in advance.
    :
    : Volkan
    :

Sign In or Register to comment.