Archive

Posts Tagged ‘Debug’

Enum bit flags visualization in VS2008 debugger!

Dumping CObject based array!

April 10, 2008 Leave a comment

Ever felt the need to dump an MFC array content to a debugger, it’s just so easy! Use AfxDump or afxDump!

Here is an e.g.

CArray IntArray;
AfxDump( &IntArray ); // Or

#ifdef _DEBUG
afxDump << IntArray; #endif[/sourcecode]

GetIconInfo caveat!

April 8, 2008 4 comments

I had heavy resource leaks in my resource digger application with my resource leak detector showing ever increasing amount of bitmap handles!

As a hint to me this was happening in my icon display function, but looking up the code I found nothing causing a leak. Analyzing closely I found that bitmap count was increasing by two, ah immediately it struck me, it’s GetIconInfo! It creates two bitmap and I was not deleting them, my fault I should’ve have read MSDN properly!. 😦

So as a summary don’t forget to delete bitmaps in an ICONINFO structure filled out by GetIconInfo because this is what the documentation says…

MSDN:

GetIconInfo creates bitmaps for the hbmMask and hbmColor members of ICONINFO. The calling application must manage these bitmaps and delete them when they are no longer necessary. 😦

For those of you who didn’t know about GetIconInfo, it’s just a function which returns mask bitmap and real bitmap for an icon. You see transparent icons because they have a mask bitmap associated with them. This function also tells us whether given icon handle represents an icon or a cursor along with hotspot co-ords for a cursor.

%d bloggers like this: