User and Graphics Device Interface Objects

User and GDI objects support only one handle per object. Processes cannot inherit or duplicate handles to user or GDI objects.

Handles to user objects are public to all processes. That is, any process can use the user object handle, provided that the process has access to the object as defined by user security. For more information about security, see Security.

Handles to GDI objects are private to a process. That is, only the process that created the GDI object can use the object handle.

In the following illustration, an application creates a window object. The CreateWindow function creates the window object and returns an object handle.

pics/WIN3200000105.gif

After the window object has been created, the application can use the window handle to display or change the window. The handle remains valid until the window object is destroyed.

In the next illustration, the application destroys the window object. The DestroyWindow function removes the window object from memory, which invalidates the window handle.

pics/WIN3200000106.gif

The following table lists the Windows user objects and each object's creator and destructor functions. The creator functions either create the object and an object handle or simply return the existing object handle. The destructor functions remove the object from memory, which invalidates the object handle.

Note that the window station and desktop objects are created and maintained by the system; applications cannot delete these objects.

User Objects

Object
Creator function
Destructor function
Accelerator table
CreateAcceleratorTable
DestroyAcceleratorTable
Cursor
CreateCursor, LoadCursor, GetCursor, SetCursor
DestroyCursor
DDE conversation
DdeConnect, DdeConnectList, DdeQueryNextServer, DdeReconnect
DdeDisconnect, DdeDisconnectList
Desktop
GetThreadDesktop

Hook
SetWindowsHook, SetWindowsHookEx
UnhookWindowsHook, UnhookWindowsHookEx
Menu
CreateMenu, CreatePopupMenu, GetMenu, GetSubMenu, GetSystemMenu, LoadMenu, LoadMenuIndirect
DestroyMenu
Window
CreateWindow, CreateWindowEx, CreateDialogParam, CreateDialogIndirectParam, CreateMDIWindow, FindWindow, GetWindow, GetClipboardOwner, GetDesktopWindow, GetDlgItem, GetForegroundWindow, GetLastActivePopup, GetOpenClipboardWindow, GetTopWindow, WindowFromDC, WindowFromPoint, and others
DestroyWindow
Window position
BeginDeferWindowPos
EndDeferWindowPos
Window station
GetProcessWindowStation

The following table lists the Windows GDI objects and each object's creator and destructor functions. The creator functions either create the object and an object handle or simply return the existing object handle. The destructor functions remove the object from memory, which invalidates the object handle.

GDI Objects

Object
Creator function
Destructor function
Bitmap
CreateBitmap, CreateBitmapIndirect, CreateCompatibleBitmap, CreateDIBitmap, CreateDIBSection, CreateDiscardableBitmap
DeleteObject
Brush
CreateBrushIndirect, CreateDIBPatternBrush, CreateDIBPatternBrushPt, CreateHatchBrush, CreatePatternBrush, CreateSolidBrush
DeleteObject
Font
CreateFont, CreateFontIndirect
DeleteObject
Palette
CreatePalette
DeleteObject
Pen
CreatePen, CreatePenIndirect
DeleteObject
Extended pen
ExtCreatePen
DeleteObject
Region
CombineRgn, CreateEllipticRgn, CreateEllipticRgnIndirect, CreatePolygonRgn, CreatePolyPolygonRgn, CreateRectRgn, CreateRectRgnIndirect, CreateRoundRectRgn, ExtCreateRegion, PathToRegion
DeleteObject
Device context (DC)
CreateDC, GetDC
DeleteDC, ReleaseDC
Memory DC
CreateCompatibleDC
DeleteDC
Metafile
CloseMetaFile, CopyMetaFile, GetMetaFile, SetMetaFileBitsEx
DeleteMetaFile
Metafile DC
CreateMetafile
CloseMetaFile
Enhanced metafile
CloseEnhMetaFile, CopyEnhMetaFile, GetEnhMetaFile, SetEnhMetaFileBits
DeleteEnhMetaFile
Enhanced-metafile DC
CreateEnhMetaFile
CloseEnhMetaFile

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database