Using Automated Annotations in Run Mode:
Take the following steps to add code, to the existing project, that will let you display annotations in run mode and activate a button annotation.
1. |
Start with the program you created in Implementing an Automated Annotation Program. |
|
2. |
Add a menu resource to the project. If you are familiar with this process, you can skip to the next step. |
|
|
a. |
From the Insert menu, select Resource. Highlight Menu and click on OK. |
|
b. |
The IDR_MENU will appear. Right click on IDR_MENU, select Properties and change the name to MAIN_MENU1. |
|
c. |
Right click on the menu entry (the outlined rectangle), and select Properties. |
|
d. |
In the Caption box enter User Mode. Make sure Pop-up is selected and press Enter. |
|
e. |
Another rectangle appears under the User Mode button on the menu. Right click on that box and select Properties. |
|
f. |
Set the ID to IDM_DESIGN and the Caption to Design Mode. Make sure Checked has been selected. Press Enter. |
|
g. |
Another rectangle appears under the Design Mode button on the menu. Right click on that box and select Properties. |
|
h. |
Set the ID to IDM_RUN and the Caption to Run Mode. Press Enter. Save the resource. |
|
i. |
Within the resource.h file in the EZAUTO directory, check the values listed for IDM_DESIGN and IDM_RUN. You can either change these values or leave them as they are, but you must define IDM_DESIGN and IDM_RUN in EZFUNC.H using the same values. |
3. |
In InitApplication, change the line: |
wcWindowClass.lpszMenuName = NULL; to
wcWindowClass.lpszMenuName = "MAIN_MENU1";
4. |
In InitInstance, change the menu parameter in CreateWindow from NULL to |
LoadMenu(hInstance, MAKEINTRESOURCE(MAIN_MENU1)).
5. |
In the MainWndProc procedure, add the following code to the switch statement: |
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDM_RUN:
L_AnnSetUserMode(hContainer, ANNUSER_RUN);
CheckMenuItem(GetMenu(hWnd), IDM_DESIGN, MF_UNCHECKED);
CheckMenuItem(GetMenu(hWnd), IDM_RUN, MF_CHECKED);
break;
case IDM_DESIGN:
L_AnnSetUserMode(hContainer, ANNUSER_DESIGN);
CheckMenuItem(GetMenu(hWnd), IDM_RUN, MF_UNCHECKED);
CheckMenuItem(GetMenu(hWnd), IDM_DESIGN, MF_CHECKED);
break;
}
return 0;
6. |
Add the following code to WM_LTANNEVENT, before return 0; |
if ((int)wParam == LTANNEVENT_AUTOCLICKED)
{
L_AnnGetType((HANNOBJECT)lParam, &uType);
if (uType == ANNOBJECT_BUTTON)
{
#ifdef UNICODE
_wsystem(TEXT("Calc"));
#else
system("Calc");
#endif
}
}
7. |
Add the following declaration to MainWndProc: |
L_UINT uType;
8. |
Build Ezfunc32.exe. |
9. |
Run Ezfunc32.exe. Create an audio annotation. Right click on the annotation and set the file to any .wav file available on your system. Create a button annotation. Right click on the annotation and change any of the button properties you wish. On the User Mode menu, select Run Mode. As you move the cursor over the audio annotation and the button annotation, the cursor changes to a hand. Click on the audio annotation to hear the .wav file. Click on the button annotation to call the program listed under WM_LTANNEVENT. |