Figures
Figure 1
Figure 1
Figure 1 Object Types with Allocation and Deallocation Functions
GDI Objects
Allocation
Deallocation
Bitmap
CreateBitmap
CreateBitmapIndirect
CreateCompatibleBitmap
CreateDIBitmap
CreateDIBSection
CreateDiscardableBitmap
LoadBitmap
LoadImage/CopyImage
DeleteObject
Brush
CreateBrushIndirect
CreateHatchBrush
CreateDIBPatternBrush
CreateDIBPatternBrushPt
CreatePatternBrush
CreateSolidBrush
DeleteObject
Display Context (DC)
CreateDC
CreateCompatibleDC
GetDC
BeginPaint
DeleteDC

ReleaseDC
EndPaint
Font
CreateFont
CreateFontIndirect
CreateFontIndirectEx
DeleteObject
Metafile
CreateXXXMetaFile
DeleteXXXMetaFile
CloseXXXMetaFile
Palette
CreatePalette
CreateHalftonePalette
DeleteObject
Path
BeginPath
EndPath
AbortPath
Pen
CreatePen
CreatePenIndirect
ExtCreatePen
DeleteObject
Region
CreateXXXRgn
CreateXXXRgnIndirect
ExtCreateRegion
PathToRegion
DeleteObject
Figure 2 Icon and Cursor Allocation and Deallocation
GDI Objects
Allocation
Deallocation
Icon
LoadImage/CopyImage
CreateIconIndirect
CopyIcon
DestroyIcon
Cursor
CreateCursor
CopyCursor
LoadImage/CopyImage
DestroyCursor
Figure 4 Running Depends.exe on Taskmgr.exe

Figure 4 Running Depends.exe on Taskmgr.exe
Figure 6 GDI Object Types
Value
Meaning
OBJ_BITMAP
Bitmap
OBJ_BRUSH
Brush
OBJ_COLORSPACE
Color space (for Image Color Management)
Not covered in this article
OBJ_DC
Device context
OBJ_ENHMETADC
Enhanced metafile DC
OBJ_ENHMETAFILE
Enhanced metafile
OBJ_EXTPEN
Extended pen
OBJ_FONT
Font
OBJ_MEMDC
Memory DC
OBJ_METAFILE
Metafile
OBJ_METADC
Metafile DC
OBJ_PAL
Palette
OBJ_PEN
Pen
OBJ_REGION
Region
Figure 8 Data Members
Data Member
In New Snapshot
In Reference
Description of Objects
m_CountByType
Unmodified
m_OutCountByType

Deleted from reference snapshot
m_NewCountByType

Created after reference snapshot
Figure 10 GDI Object Types
Type
Description
OBJ_BITMAP
The bitmap is displayed using BitBlt
OBJ_BRUSH
A rectangle is filled with the brush
OBJ_COLORSPACE
Not covered in this article
OBJ_DC
The bitmap of the DC is shown using BitBlt
OBJ_ENHMETADC
None
OBJ_ENHMETAFILE
Plays the enhanced metafile into the DC
OBJ_EXTPEN
A rectangle is framed with borders using the pen
OBJ_FONT
Alphabet and digits are written with the font
OBJ_MEMDC
The bitmap of the DC is shown using BitBlt
OBJ_METAFILE
Plays the metafile into the DC
OBJ_METADC
None
OBJ_PAL
Counts palette entries and displays a palette wheel
OBJ_PEN
A rectangle is framed with borders using the pen
OBJ_REGION
Gives the bounding rectangle dimensions
Figure 13 GetObjectType Returns Incorrect Information
   HBRUSH   hBrush;
   DWORD    dwObjectType;
   LOGBRUSH logBrush;
   
   hBrush = ::CreateSolidBrush(RGB(0, 0, 0));
   dwObjectType = ::GetObjectType(hBrush);
   TRACE(
      "0x%x is a %s\n", 
      hBrush, 
      (dwObjectType == OBJ_BRUSH) ? "OBJ_BRUSH" : "?"
      );
   if (::GetObject(hBrush, sizeof(logBrush), &logBrush) != 0)
      TRACE("—> valid brush\n");
   else
      TRACE("—> invalid brush\n");

   ::DeleteObject(hBrush);

   dwObjectType = ::GetObjectType(hBrush);
   TRACE(
      "After deletion: 0x%x is a %s\n", 
      hBrush, 
      (dwObjectType == OBJ_BRUSH) ? "OBJ_BRUSH" : "?"
      );
   if (::GetObject(hBrush, sizeof(logBrush), &logBrush) != 0)
      TRACE("—> valid brush\n");
   else
      TRACE("—> invalid brush\n");
   TRACE("\n");
Figure 16 MenuUsage Output after Notepad Launches
&File ]>
   [9] &New
   [10] &Open...
   [1] &Save
   [2] Save &As...
   ——————————————
   [32] Page Se&tup...
   [14] &Print
   ——————————————
   [28] E&xit

&Edit ]>
   [25] &Undo    Ctrl+Z
   ——————————————
   [768] Cu&t    Ctrl+X
   [769] &Copy    Ctrl+C
   [770] &Paste    Ctrl+V
   [771] De&lete    Del
   ——————————————
   [7] Select &All
   [12] Time/&Date    F5
   ——————————————
   [27] &Word Wrap
   [37] Set &Font...

&Search ]>
   [3] &Find...
   [8] Find &Next    F3

&Help ]>
   [5] &Help Topics
   ——————————————
   [11] &About Notepad
Page view tracker