You can call a GDI function and pass a DC to the function to draw lines, circles, or text. Commonly, you should call a function like GetClientDC or CreateCompatibleDC to get or create a DC, then call GDI functions to draw objects, e.g. MoveTo and LineTo. After finishing drawing, you should call ReleaseDC or DeleteMemDC function to release or destroy the DC.
MiniGUI reserved an global DC called HDC_SCREEN. You can use this DC directly without getting/creating or releasing/destroying.
For main windows or controls, MiniGUI will send a MSG_PAINT message to the window when the whole or part of window area have been invalidated. You should call BegainPaint function to get the DC, then repaint the window, and call EndPaint function to release the DC at the last.
Example:
case MSG_PAINT: { HDC hdc; hdc = BeginPaint (hWnd); // Draw a line. MoveTo (hdc, 0, 0); LineTo (hdc, 100, 100); EndPaint (hWnd, hdc); break; }
|
|
Creates a memory DC which is compatible with a given DC. This function creates a memory DC fully compatible with the reference DC hdc, including pixel format and geomatry.
|
|
|
Deletes a memory DC. This function deletes a memory DC created by CreateCompatibleDC.
|
|
|
Indicates an invalid handle to device context.
|
|
|
Handle to the device context of the whole screen. This DC is a special one. MiniGUI uses it to draw popup menus and other global objects. You can also use this DC to draw lines or text on the screen directly, and there is no need to get or release it. If you do not want to create any main window, but you want to draw on the screen, you can use this DC.
|
|
||||||||||||||||
|
Converts a memory DC to have a same format as a reference DC. This function converts a memory DC mem_dc in order to let it have the same pixel format as the reference DC ref_dc. This function will try to create a new surface for mem_dc, and then copies and maps the surface of ref_dc to it so the blit of the converted memory DC will be as fast as possible. The flags parameter has the same semantics as CreateMemDC. You can also pass MEMDC_FLAG_RLEACCEL in the flags parameter and MiniGUI will try to RLE accelerate colorkey and alpha blits in the resulting memory DC.
|
|
||||||||||||||||
|
Creates a memory DC which is compatible with the specified reference DC. This function creates a memory DC which have the same pixel format as the specified reference DC hdc. The same pixel format means that the memory DC will have the same pixel depth, the same RGB composition, or the same palette as the reference DC.
|
|
||||||||||||||||||||||||||||||||||||
|
Creates a memory DC. This function creates a memory DC which have the specified flags and pixel format.
|
|
||||||||||||
|
Creates a memory DC from a reference DC and a BITMAP object. This function creates a memory DC compatible with the specified DC, and use the bits of the BITMAP object as the surface of the memory DC. The created memory DC will have the same geometry as the BITMAP object.
|
|
||||||||||||
|
Creates a memory DC from a device independent MYBITMAP object. This function creates a memory DC which have the same pixel format as the MYBITMAP object my_bmp, and use the bits of the MYBITMAP object as the surface of the memory DC. The created memory DC will have the same geometry as the MYBITMAP object. If the depth of my_bmp is 8-bit, the function will use pal to initialize the palette of the memory DC.
|
|
|
Creates a private client DC of a window. This function creates a private client DC of the window hwnd and returns the handle to the DC. When you calling CreatePrivateClientDC function to create a private client DC, MiniGUI will create the DC in the system heap, rather than allocate one from the DC pool. Thus, you can keep up the DC in the life cycle of the window, and are not needed to release it for using by other windows.
|
|
|
Creates a private window DC of a window. This function creates a private window DC of the window hwnd and returns the handle to the DC. When you calling CreatePrivateDC function to create a private DC, MiniGUI will create the DC in the system heap, rather than allocate one from the DC pool. Thus, you can keep up the private DC in the life cycle of the window, and are not needed to release it for using by other windows.
|
|
|
Deletes a memory DC. This function deletes the memory DC mem_dc, and frees the surface of the DC. For the memory DC created from BITMAP object or MYBITMAP object, the bits used by the surface of the DC will be reserved.
|
|
|
Deletes the DC returned by CreatePrivateDC or CreatePrivateClientDC.
|
|
|
Gets a client DC of a window. This function gets a client DC of the specified hwnd, and returns the handle to the DC. MiniGUI will try to return an unused DC from the internal DC pool, rather than allocate a new one from the system heap. Thus, you should release the DC when you finish drawing as soon as possible.
|
|
|
Gets a window DC of a window. This function gets a window DC of the specified hwnd, and returns the handle to the DC. MiniGUI will try to return an unused DC from the internal DC pool, rather than allocate a new one from the system heap. Thus, you should release the DC when you finish drawing as soon as possible.
|
|
||||||||||||
|
Returns a capability of a DC. This function returns the capability of the specified item iItem of the DC hdc.
|
|
|
Returns the private client DC of a window. This function returns the private client DC of the window hwnd which have extended style WS_EX_USEPRIVATECDC. When a main window have the extended style WS_EX_USEPRIVATECDC, or a control class have the style CS_OWNDC, MiniGUI will create a private client DC for this window in the creation progress of the window, and destroy the DC when you destroy the window, and use this private client DC in default message handlers. So there will be some improvments on drawing/repaint performance. You can alos call this function to get the private client DC, and use it to draw anything in your window.
|
|
||||||||||||||||||||||||
|
Locks a dc to get direct access to pixels in the DC. Calling this function will try to lock the DC hdc to directly access the pixels of the DC. You should tell this function the rectangle to be accessed, and the function will return the effective width, height and pitch of the DC. The access beyond effective width and height will be invalid. Locking a DC which uses screen surface will lock some global objects, such as mouse cursor, and so on. All GDI calls of other threads (in MiniGUI-Threads) or other process (in MiniGUI-Processes) will be blocked as well. So you should call UnlockDC to unlock the DC as soon as possible, and should not call any system function in the duration of locking the DC.
/* * lock the dc and draw the scan line with random color. */ int i, width, height, pitch; RECT rc = {0, 0, 200, 200}; int bpp = GetGDCapability (hdc, GDCAP_BPP); Uint8* frame_buffer = LockDC (hdc, &rc, &width, &height, &pitch); Uint8* row = frame_buffer; for (i = 0; i < *height; i++) { memset (row, rand ()%0x100, *width * bpp); row += *pitch; } UnlockDC (hdc); |
|
|
Releases a DC from DC pool. This function releases the DC returned by GetDC or GetClientDC.
|
|
||||||||||||||||
|
Sets the alpha value for the entire surface of a DC, as opposed to using the alpha component of each pixel. This function sets the alpha value for the entire surface of the DC mem_dc, as opposed to using the alpha component of each pixel. This value measures the range of transparency of the surface, 0 being completely transparent to 255 being completely opaque. An alpha value of 255 causes blits to be opaque, the source pixels copied to the destination (the default). Note that per-surface alpha can be combined with colorkey transparency. If flags is 0, alpha blending is disabled for the surface. If flags is MEMDC_FLAG_SRCALPHA, alpha blending is enabled for the surface. OR'ing the flag with MEMDC_FLAG_RLEACCEL requests RLE acceleration for the surface; if MEMDC_FLAG_RLEACCEL is not specified, the RLE acceleration will be removed.
|
|
||||||||||||||||
|
Sets the color key (transparent pixel) of a memory DC. This function sets the color key (transparent pixel) of the memory DC mem_dc. If flags is MEMDC_FLAG_SRCCOLORKEY (optionally OR'ed with MEMDC_FLAG_RLEACCEL), color_key will be the transparent pixel in the source DC of a blit. MEMDC_FLAG_RLEACCEL requests RLE acceleration for the source of the DC if present, and removes RLE acceleration if absent. If flags is 0, this function clears any current color key.
|
|
|
Unlocks a locked DC.
|
1.4.2