Functions that Get\/Release Handle Device Context
BT_CreateDC(Win_or_hBitmap, Type, @BTstruct)
Returns the handle to the device context specified (hDC).
Type: specifies the type of the handle device context to get, can be one of the following constants: BT_HDC_DESKTOP (hDC to desktop), BT_HDC_WINDOW (hDC to all window), BT_HDC_ALLCLIENTAREA (hDC to the all client area),
BT_HDC_INVALIDCLIENTAREA (hDC to the region of the client area that is not valid: invalid client area, i.e. needs to be repainted) or BT_HDC_BITMAP (hDC to a bitmap) (defined in BosTaurus.CH).
Win_or_hBitmap: is the name (e.g. "Win1") or is the handle (e.g. hWin) to the window if Type is set as BT_HDC_WINDOW, BT_HDC_ALLCLIENTAREA or BT_HDC_INVALIDCLIENTAREA. Win_or_hBitmap is a handle to bitmap (hBitmap) if Type is set as BT_HDC_BITMAP. If Type is set as BT_HDC_DESKTOP, Win_or_hBitmap is ignored.
BTstruct: is a variable (array) passed by reference that stores information about the hDC obtained. This information is necessary to properly release the hDC obtained.
BT_DeleteDC(BTstruct)
Release from the memory a handle of device context.
BTstruct: is an array with information about a determined handle of device context returned by BT_CreateDC function.
Remarks
The Bos Taurus graphic library uses the common Device Contexts (DC). The common DCs are _Display _device contexts maintained in a special cache by the system. Because only a limited number of common device contexts exist, an application should release them after it has finished drawing. Because new display device contexts for the cache are allocated in the application's heap space, failure to release the device contexts eventually consumes all available heap space this causes an error when it cannot allocate space for the new device context. This means that you should get the hDC, draw and then immediately release the hDC, do not store the hDC to process other events drawing later.
The best way to process the ON PAINT event in HMG is get the handle of the Device Context (hDC) of the client area with Type = BT_HDC_INVALIDCLIENTAREA in the BT_CreateDC function. This way is fast for drawing and causes less display flicker that with BT_HDC_ALLCLIENTAREA. The handle of the DC obtained with BT_HDC_ALLCLIENTAREA is indicated to paint the client area out of the ON PAINT event.