Thread: GDI memory leaks: what are the situations that we can't delete a GDI object?

  1. #1
    Registered User
    Join Date
    Aug 2013
    Posts
    434

    GDI memory leaks: what are the situations that we can't delete a GDI object?

    i have these on my image class:
    Code:
    void Brush(COLORREF BrushColor)
        {
            if(DeleteBrush(imgBrush)==FALSE)
                DebugText("brush color not deleted");
            imgBrush=CreateSolidBrush(BrushColor);
            //DeleteBrush(BrushColor);
        }
    - the imgBrush it's a HBRUSH object;
    - the imgBrush isn't selected to any HDC.
    so why i can't delete it?

  2. #2
    Registered User
    Join Date
    Mar 2011
    Posts
    596
    Did you try DeleteObject(imgBrush)?

    -

  3. #3
    Registered User winuser's Avatar
    Join Date
    Apr 2016
    Location
    POLAND
    Posts
    5
    Try to get an extended error information using GetLastError() function and then just read details about your error code.

    Here's the list of error codes:
    System Error Codes (Windows)

  4. #4
    Registered User
    Join Date
    Aug 2013
    Posts
    434
    i did i big mistake without know it. and was not on Brush() but on a FillRectangle(), because i was creating the brush on a parameter and not on a variable.
    sorry and thanks to all

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory leaks in spite of using delete[]
    By bot in forum C++ Programming
    Replies: 8
    Last Post: 12-30-2015, 01:45 PM
  2. need to delete an object to free memory
    By baxy in forum C++ Programming
    Replies: 7
    Last Post: 12-10-2013, 05:38 AM
  3. Replies: 6
    Last Post: 10-15-2012, 05:16 PM
  4. delete object from inside object
    By Drogin in forum C++ Programming
    Replies: 10
    Last Post: 01-02-2009, 08:55 PM
  5. Memory usage and memory leaks
    By vsanandan in forum C Programming
    Replies: 1
    Last Post: 05-03-2008, 05:45 AM

Tags for this Thread