Introduction to the Windows CE High-Speed Graphics Library


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

Environment: Windows CE


CE Draw is high-speed graphics library in Windows CE. It depends on GAPI. This code was writen in C++ and uses embedded Visual C++ to compile it. It was tested on an iPaq h3600 with Windows CE 3.0. CE Draw uses double buffer and direct-write video buffer technology to enhance Draw's speed. With its own graphics arithmetic, the draw speed is much faster than WinGDI.

CE Draw supports these functions:

  • Draw Pixel
  • Fill Screen
  • Draw Line, HLine, VLine
  • Draw Polyline
  • Draw Polygon
  • Draw Rectangle
  • Fill Rectangle (with alpha blend support)
  • Fill Polygon
  • Draw Bitmap (supports Bmp, Gif, and Jpg formats; also supports alpha blend)
  • Draw Text (Own font file, supports Chinese and gdi text)

SDKSample Screen Shot:

How to Use It

Before you use the CE Draw Library, you must copy some support files to you system.

Copy the DLL to your Windows CE system directory

If you are using the program in an emulation system, copy two of the DLLs in the \CEGraph\DLL\X86Em directory (gx.dll and cegl.dll) to the emulation windows system directory, always in D:\Windows CE Tools\wce300\MS Pocket PC\emulation\palm300\windows. Then copy the file Hzk16, which is in the \CEGraph\Res directory to the WinCE Root directory. It is always in D:\Windows CE Tools\wce300\MS Pocket PC\emulation\palm300.

If you are using the program in an Arm system, copy two of the DLLs in \CEGraph\DLL\Arm (gx.dll and cegl.dll) to the Pocket PC Windows system directory. Then copy the file HZK16 to the System Root directory.

There are four steps to using it:

  1. Step 1: Directory
    Set the including directory to \CEGraph\Include
    And lib directory to \CEGraph\Lib\X86Em (if using in an emulation system)
    Or \CEGraph\Lib\Arm (if using on a Pocket PC system)

    Open the project: Setting->Link->Object/library Modules

    Add CEGL.lib

  2. Step 2: Head File Including
    Include the CE Draw graphics header file CEGL.h

    #include "stdafx.h"
    #include "SDKSample.h"
    #include <commctrl.h>
    #include <cegl.h> // Include CE Graphics library
  3. Step 3: Create the CE Draw Class

    // Create the CE Draw Object>
    CCEDraw m_ceDraw;
    // Initlizate after CreateWindow()
    BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
    HWND hWnd;
    TCHAR szTitle[MAX_LOADSTRING];       // The title bar text
    TCHAR szWindowClass[MAX_LOADSTRING]; // The window class name
    hInst = hInstance; // Store instance handle in our global variable
                       // Initialize global strings
     LoadString( hInstance, 
     MyRegisterClass(hInstance, szWindowClass);
     LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
     hWnd = CreateWindow( szWindowClass, 
                          0, 0, 
     if (!hWnd)
       return FALSE;
    // Create the CE Grahpics Library
    m_ceDraw.Create( hWnd );
    ShowWindow(hWnd, nCmdShow);
    return TRUE;
  4. Step 4: Using CE Draw Freely

                              UINT message, 
                              WPARAM wParam,
                              LPARAM lParam)
      HDC hdc;
      int wmId, wmEvent;
      switch (message)
       case WM_PAINT:
       RECT rt;
       hdc = BeginPaint(hWnd, &ps);
       GetClientRect(hWnd, &rt);
       LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
       DrawText(hdc, szHello, _tcslen(szHello), &rt,
       EndPaint(hWnd, &ps);
       Render(); // Render screen
    void Render( void )
      POINT pt[5] ={ { 140, 100 }, 
                     { 70,120 }, 
                     { 104, 150 },
                     { 210, 122 }, 
                     { 75, 200 } };
    // Create the CE pen object...
    CCEPen cePen;
    cePen.CreatePen( 1, 1, m_ceDraw.ConvertColor( 255, 0, 0 ) );
    // Convert RGB color to CE support Color
    // Select it to the graphics system
    m_ceDraw.SetGDIObject( &cePen );
    // Create the CE brush object...
    CCEBrush ceBrush1, ceBrush2;
    ceBrush1.CreateBrush( 1, m_ceDraw.ConvertColor( 200, 200, 100 ), 1);
    ceBrush2.CreateBrush( 1, m_ceDraw.ConvertColor( 0, 240, 0 ), 1 );
    // Select it to the graphics system
    m_ceDraw.SetGDIObject( &ceBrush1 );
    // Begin Draw
    m_ceDraw.Clear( (DWORD)255 );
      // Clear screen use white color
    m_ceDraw.DrawLine( 1, 1, 100, 100 );   // Draw line
    m_ceDraw.DrawRect( 10, 10, 110, 80 );  // Draw Rect
    m_ceDraw.FillRect( 30, 30, 50, 50 );   // Fill Rect
    m_ceDraw.SetGDIObject( &ceBrush2 );    // Select another color brush
    m_ceDraw.FillRect( 40, 40, 100, 100, 0.4 );
                                           // fill Rect with alpha blend
    m_ceDraw.FillPolygon( pt, 5 );         // Draw a polygon
    m_ceDraw.SetGDIObject( &ceBrush1 );    // Select another color brush
    m_ceDraw.FillPolygon( pt, 5, 40, 40 ); // Draw a polygon
    CCEBitmap ceBmp1,ceBmp2;
    ceBmp1.LoadBitmap( &m_ceDraw, L"windows\\wcelogo1.gif" );
    // Load Gif picture from file
    ceBmp2.LoadBitmap( &m_ceDraw, L"windows\\welcomehead.gif" );
    ceBmp2.BitBlt( &m_ceDraw, 1, 80, 0, 0, 0, 0, SRCALPHA, 0.6f );
    // Draw bitmap with alpha blend
    ceBmp1.BitBlt( &m_ceDraw, 1, 200, 0, 0, 0, 0, SRCALPHA, 0.6f );
    POINT ptText = { 1, 300 };
    m_ceDraw.DrawText( &ptText, "Hello CE Graph!", 16, 1 );
    // Draw text with pen color
    // End Draw
    m_ceDraw.Flip();  // Flip the back buffer to the video buffer
  5. Step 5: Releasing Memory

    Don't forget to release it.
    case WM_DESTROY:


This graphics package cannot be directly used in a MFC appwizard-generated frame because it has two windows; one is a frame window and the other is a child window. I've written a frame code that supports MFC. If anyone wants to use it in MFC, write mail to me.

  • The CEGLDLLPrj is the DLL project of CE Graphics Library. It's highly recommended that, if you want to use this library, use the project to build your own DLL and Lib files. To build this project, you can set the include and lib directories with ...\CEGraph\include and lib. (The is the same as Step 1's Directory.)
  • The SDK Sample Project is the sample not using MFC. Build it after setting and copying the library and DLL files.


Please report any bugs or feedback to jiet@msn.com. Thanks.

This code uses GAPI Enum. Thanks to the writer.


Download Source - 307 Kb


  • Can I emulate this code on X86 Emulation mode?

    Posted by Legacy on 11/18/2003 08:00am

    Originally posted by: Seunghun Lee

    First of all, thank you for providing this wonderful source.
    But I have a question about this code.
    When I open this project at first time, I noticed that this project is for ARM environment. But when I added X86 environment to this project, I couldn't compile 'CEGLDLLPrj'.

    Could you tell me how I can resolve this problem? Please let me know.

    Thank you in advance.

  • How can I run it on EVC 4.0?

    Posted by Legacy on 06/01/2003 07:00am

    Originally posted by: Tian

    I follow steps you said on EVC 3.0, and create a new program like sdksample on EVC 4.0.
    But after successful compiled and builded, the program can't run on the standsdk emulator.

    1. evc 4->execute ***.exe (Ctrl+F5): error
    Can't execute program
    2. emulator: run the program
    Can't find '***'(or one of it's components). Make sure the path and the filename are correct and that all the required libraries are avalible.

    Maybe the program on the emulator can't find gx.lib and cegl.lib, but I don't know how I can set the path. I alread have copyed gx.h and cegl.h to D:\Windows CE Tools\wce400\STANDARDSDK\Include\Emulator and copied gx.lib, cegl.h and HZK16 to D:\Windows CE Tools\wce400\STANDARDSDK\Lib\Emulator.

  • give me some advice.

    Posted by Legacy on 04/02/2003 08:00am

    Originally posted by: yiyang

    the linker can't find the functions implemented in the gx.lib.(I have put gx.lib to the dir.)

  • GAPI_Emu.h not found

    Posted by Legacy on 03/12/2003 08:00am

    Originally posted by: dnka

    i'm getting the above msg when i compile. can you explain this further?


    #ifndef GDI_ENUM
    #include "Gx.h"
    #include "GAPI_Emu.h"


  • Failed to build an application using the sample code.

    Posted by Legacy on 01/03/2003 08:00am

    Originally posted by: joe

    I've tried the quick and dirty route to using the sample code you supplied. After resolving paths to the include files, I'm getting unresolved errors for things like MAX_LOADSTRING

    You don't happen to have a zipped up project you could post that uses the DLL you've provided, do you?


  • Do you have GX.DLL code?

    Posted by Legacy on 08/07/2002 07:00am

    Originally posted by: Asaf Fried

    Do you have GX.DLL code?

  • How did you find?

    Posted by Legacy on 07/11/2002 07:00am

    Originally posted by: Bill

    How did you find things like exported functions from imgdcmp.dll?? I cant find documentation on that anywhere...

    Anyway, great job!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date