Win32 ShowWindow() function "gdi object" leak

Win32 ShowWindow() function "gdi object" leak

Post by twinkl » Sat, 11 Mar 2006 21:29:30

Hi, I have a gdi object leak that I cannot get rid of... (I am using

Every time I use the ShowWindow() function to Show or Hide a window
lots of gdi objects are created and they just multiply as windows are
shown/hidden. Even a function like SetDlgItemText() create 2 new gdi
objects every time a little bit of text is sent to a static control.

Q: why do I get all these gdi objects created? I have always thought
that a particular window was a gdi object (or a couple, who knows) and
that the same gdi objects were used each time something happened with
the window?

Please help me solve this, best regards

Win32 ShowWindow() function "gdi object" leak

Post by James Brow » Sat, 11 Mar 2006 23:02:41

how are you determining this?

GDI objects get created because your program creates them. Use
"BoundsChecker" to verify where the handle-leaks are occurring


Microsoft MVP - Windows SDK
Free Win32 Source and Tutorials


Win32 ShowWindow() function "gdi object" leak

Post by Kellie Fit » Sun, 12 Mar 2006 00:10:03


The following webLink could help you out with GDI object leaks:

Hope this suggestion helps,


Win32 ShowWindow() function "gdi object" leak

Post by Ben Voig » Thu, 23 Mar 2006 05:24:13

You're calling win32 api directly, with no MFC or other wrapper class?
Wrapper items could easily be leaked.
Those win32 functions don't create objects. However, the message loop or
window procedure which are triggered could. ShowWindow will trigger
WM_PAINT, SetDlgItemText will cause WM_PAINT in the control. Are things
subclassed? Hooked?