Before use the CEDraw
Library, you must copy some
support file in you system.
a. Copy the dll to you
WinCE system
directory
Open the project
setting->Link->Object/library
Modules
CCEDraw m_ceDraw;
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
TCHAR szTitle[MAX_LOADSTRING]; TCHAR szWindowClass[MAX_LOADSTRING];
hInst = hInstance; LoadString(hInstance, IDC_SDKSAMPLE, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance, szWindowClass);
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
hWnd = CreateWindow(szWindowClass, szTitle, WS_VISIBLE,
0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
m_ceDraw.Create( hWnd );
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
Step 4: Using CE
Draw
freely
Collapse |
Copy Code
LRESULT CALLBACK WndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
HDC hdc;
int wmId, wmEvent;
PAINTSTRUCT ps;
TCHAR szHello[MAX_LOADSTRING];
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,
DT_SINGLELINE | DT_VCENTER | DT_CENTER);
EndPaint(hWnd, &ps);
Render(); break;
...
}
}
void Render( void )
{
POINT pt[5] ={ { 140, 100 }, { 70,120 }, { 104, 150 },
{ 210, 122 }, { 75, 200 } };
CCEPen cePen;
cePen.CreatePen( 1, 1, m_ceDraw.ConvertColor( 255, 0, 0 ) );
m_ceDraw.SetGDIObject( &cePen );
CCEBrush ceBrush1, ceBrush2;
ceBrush1.CreateBrush( 1, m_ceDraw.ConvertColor( 200, 200, 100 ), 1 );
ceBrush2.CreateBrush( 1, m_ceDraw.ConvertColor( 0, 240, 0 ), 1 );
m_ceDraw.SetGDIObject( &ceBrush1 );
m_ceDraw.BeginDraw();
m_ceDraw.Clear( (DWORD)255 );
m_ceDraw.DrawLine( 1, 1, 100, 100 );
m_ceDraw.DrawRect( 10, 10, 110, 80 );
m_ceDraw.FillRect( 30, 30, 50, 50 );
m_ceDraw.SetGDIObject( &ceBrush2 ); m_ceDraw.FillRect( 40, 40, 100, 100, 0.4 );
m_ceDraw.FillPolygon( pt, 5 ); m_ceDraw.SetGDIObject( &ceBrush1 ); m_ceDraw.FillPolygon( pt, 5, 40, 40 );
CCEBitmap ceBmp1,ceBmp2;
ceBmp1.LoadBitmap( &m_ceDraw, L"windows\\wcelogo1.gif" );
ceBmp2.LoadBitmap( &m_ceDraw, L"windows\\welcomehead.gif" );
ceBmp2.BitBlt( &m_ceDraw, 1, 80, 0, 0, 0, 0, SRCALPHA, 0.6f );
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 );
m_ceDraw.EndDraw();
m_ceDraw.Flip(); }
Step 5:
Don’t forgot to release
it:
Collapse |
Copy Code
case WM_DESTROY:
m_ceDraw.Release();
PostQuitMessage(0);
break;
Tips:
This
graphics library
cannot be directly used in
an MFC appwizard generated
frame. Because it has two
windows, one is frame
window, the other is child
Window. I’ve write a
Framework that supports MFC.
If anyone who want to use it
in MFC email me.
- The CEGLDLLPrj is
the dll project of CE
Graphics Library.
It's high recommend that
if you want to use this
library, use the project
to build your own DLL &
Lib Files. To Build this
project. You Can setting
the include directory
and lib directory with
...\CEGraph\include &
lib (The same as Step 1
Directory )
- The SDKSample
Project is the sample
NOT using MFC. Build it
after setting & copying
the library& DLL Files.