Implementing a Non-automated Annotations Program
Take the following steps to create and run a program that implements non-automated annotations.
1. |
Create a new directory in the LTWINxxx\EXAMPLES\DLL directory called EZNON. |
2. |
Copy everything in the EZFUNC directory into the EZNON directory. |
3. |
Compile the project as is and run EZFUNC32.exe to familiarize yourself with the program. You can run the exe file from the MS-DOS prompt, or set the image file to load through the Build -> Settings ->Debug->Program Arguments menu. |
4. |
On the Insert menu, select Files into Project. Add the Ltann_n.lib file to the project from the LTWINxxx\LIB directory. |
5. |
Declare the following global variables: |
HANNOBJECT hContainer;
HANNOBJECT MyNote;
and the following functions:
void TestCreateAnn(HWND hWnd);
void TestCreateNoteAnn(HWND hWnd);
6. |
Add the following code: |
void TestCreateAnn(HWND hWnd)
{
RECT rClientArea; /* Client area of the current window */
HDC hWindowDC; /* Device context of the current window */
ANNRECT ContainerRect; /* Defining rectangle for the container */
RECT rAnnBounds; /* Bounding rectangle for displaying */
/* Get the device context of the current window */
hWindowDC = GetDC (hWnd);
/* Get the client area of the current window */
GetClientRect(hWnd, &rClientArea);
/* Create the annotation container, which we will use as the root container */
ContainerRect.left = 0;
ContainerRect.top = 0;
ContainerRect.right = BITMAPWIDTH(&LeadBitmap) -1;
ContainerRect.bottom = BITMAPHEIGHT(&LeadBitmap) - 1;
L_AnnCreateContainer(hWnd, &ContainerRect, TRUE, &hContainer);
/* Set the annotation scalars and offsets, assuming that the display
dimensions are the same as the client area dimensions */
L_AnnSetScalarX(hContainer, (L_DOUBLE) rClientArea.right / BITMAPWIDTH(&LeadBitmap), 0);
L_AnnSetScalarY(hContainer, (L_DOUBLE) rClientArea.bottom / BITMAPHEIGHT(&LeadBitmap), 0);
L_AnnSetOffsetX(hContainer, (L_DOUBLE) 0, 0);
L_AnnSetOffsetY(hContainer, (L_DOUBLE) 0, 0);
L_AnnGetBoundingRect(hContainer, &rAnnBounds, NULL);
L_AnnDraw(hWindowDC, &rAnnBounds, hContainer);
ReleaseDC(hWnd, hWindowDC);
return;
}
7. |
Add the following code: |
void TestCreateNoteAnn(HWND hWnd)
{
ANNRECT ContainerRect;
ANNRECT MyNoteRect;
RECT rAnnBounds;
HDC hWindowDC;
hWindowDC = GetDC(hWnd);
/* Create a Note Annotation */
L_AnnCreateItem(hContainer, ANNOBJECT_NOTE, TRUE, &MyNote);
L_AnnGetRect(hContainer, &ContainerRect, NULL);
/* Size and position the note */
MyNoteRect.left = ContainerRect.right / 8;
MyNoteRect.top = ContainerRect.bottom / 8;
MyNoteRect.right = ContainerRect.right / 2;
MyNoteRect.bottom = ContainerRect.bottom / 2;
L_AnnSetRect(MyNote, &MyNoteRect);
/* Set the text of the note */
L_AnnSetText(MyNote, TEXT("This is my text"), 0);
L_AnnSetBackColor(MyNote, RGB(0, 255, 255), 0);
L_AnnSetFontBold(MyNote, TRUE, 0);
L_AnnSetFontItalic(MyNote, FALSE, 0);
L_AnnSetFontName(MyNote, TEXT("Arial"), 0);
L_AnnSetFontSize(MyNote,16, 0);
L_AnnSetFontStrikeThrough(MyNote, FALSE, 0);
L_AnnSetFontUnderline(MyNote, TRUE, 0);
L_AnnSetForeColor(MyNote, RGB(255, 0, 0), 0);
/* Display the note */
L_AnnGetBoundingRect(MyNote, &rAnnBounds, NULL);
L_AnnDraw(hWindowDC, &rAnnBounds, MyNote);
/* Remove the queued paint message */
ValidateRect(hWnd, &rAnnBounds);
ReleaseDC(hWnd, hWindowDC);
return;
}
8. |
Add the following lines of code to WM_CREATE, just before return (TRUE); : |
TestCreateAnn(hWnd);
TestCreateNoteAnn(hWnd);
9. |
Add the following line to WM_PAINT, immediately after |
if(hpalPaint)
SelectPalette(hdc, hPalette, FALSE); :
L_AnnDraw(hdc, &ps.rcPaint, hContainer);
10. |
Add the following line to WM_DESTROY, immediately before “/* Post WM_QUIT to end the application */” : |
L_AnnDestroy(hContainer, ANNFLAG_RECURSE);
11. |
On the Build menu, select Build Ezfunc32.exe. |
12. |
On the Build menu, select Execute Ezfunc32.exe. Keep this project for testing other annotation code samples and for implementing Using Non-automated Annotations in Run Mode. |