Available in the LEADTOOLS Imaging toolkit. |
Using a PanWindow (Visual C++ 5.0 or later)
Take the following steps to start a project and to add some code that opens and displays an image file and allows you to bring up a PanWindow.
1. Start a new project as follows:
For C++ 4.x, run Microsoft Developer Studio for Visual C++, select the File >New menu option, select Project Workspace, and click the OK button. In the New Project Workspace dialog box, do the following:
a. In the Type list box, select MFC AppWizard (exe).
b. In the Name text box, specify pan.
c. In the Location text box, specify the path of the project.
d. In the Platforms list box, check Win32.
e. Click the Create button.
For C++ 5.0, run Microsoft Visual C++ 5.0, select the File >New menu option, and do the following:
a. Click the Projects tab.
b. Select MFC AppWizard (exe) as the project type
c. In the Project name text box, specify pan.
d. In the Location text box, specify the path of the project.
e. Click the OK button.
2. In the Step 1 dialog box, do the following:
a. Select Dialog based.
b. Click the Next button.
3. In the Step 2 of 4 dialog box, do the following:
a. Ensure that About Box is selected.
b. Ensure that 3D controls is selected.
c. Select ActiveX controls.
d. Click the Next button.
4. In the Step 3 of 4 dialog box, do the following:
a. For comments, ensure that Yes, Please is selected.
b. For how to use the MFC library, select As a shared DLL.
c. Click the Next button.
5. In the Step 4 of 4 dialog box, just click Finish.
6. Read New Project Information, and click OK. (The AppWizard creates the project files and opens the project.)
7. Add the L_OCX.H and l_OcxErr.H files to your project as follows:
a. Copy the L_OCX.H and l_ocxerr.h files to your project directory, from the \lead\include\ directory.
b. In the Project Workspace, click the FileView tab.
c. Double-click the pan files folder to open it.
d. Double-click the Dependencies folder (the Header Files folder in 5.0) to open it.
e. Double-click the StdAfx.h file to edit it.
f. Add the following lines to the end of the file:
#include "L_OCX.H"
8. Add a LEAD control to the main window as follows:
a. In the Project Workspace, click the ResourceView tab.
b. Double-click the pan resources folder to open it.
c. Double-click the Dialog folder to open it.
d. Double-click IDD_PAN_DIALOG to design the dialog box.
e. Select the TODO... text control; then press the Delete key to delete it.
f. From the main menu, select Project > Add To Project > Components and controls.
g. Select Registered ActiveX controls.
h. Double-click the LEAD Main ActiveX Control (16) icon. (The Confirm Classes dialog box appears.)
i. Ensure that CLead, CPicture, and COleFont are checked.
j. Click OK to complete the selection, then click Close to close the Component Gallery. (The LEAD controls appears in the controls toolbar.)
k. Click the LEAD Main Control icon; then size and position the control as you want it to appear at run time.
l. Use the right mouse button to edit the properties of the new LEAD Main Control.
m. Change the ID to IDC_LEAD1.
9. Add a command button to your form and name it as follows:
ID |
Caption |
IDC_PANWIN |
Show Pan Window |
10. Add a Check box control to the main window and set the ID and Caption as follows:
ID |
Caption |
IDC_CHECK1 |
Pan Window |
11. Press Ctrl-F4 to close all windows back to the Project Workspace.
12. Do the following to add m_LEAD1 and m_Check1 to the CPanDlg class and link the variable to the controls using dynamic data exchange:
a. Press Ctrl-W. (The MFC ClassWizard dialog box appears.)
b. Click the Member Variables tab.
c. In the Class Name box, select CPanDlg.
d. In the Control IDs list, select IDC_LEAD1.
e. Click the Add Variable... button.
f. Specify m_LEAD1 as the variable name, and control as the category.
g. Click OK to close the dialog box.
h. Back in MFC Wizard, go to the Member Variables tab, and ensure CDlgTutorDlg is in the Class Name box.
i. In the Control IDs list, select IDC_CHECK1.
j. Click the Add Variable... button.
k. Specify m_Check1 as the variable name, and control as the category.
l. Click OK to close the dialog box, and click OK to close the MFC ClassWizard.
13. Press Ctrl-W to go to the MFC Class Wizard; then do the following:
a. Click the Message Maps tab.
b. In the Class Name combo box, select CPanDlg.
c. In the Object IDs list box, select IDC_PANWIN.
d. In the Messages list box, select BN_CLICKED.
e. Click the Add function button. Choose OK for the default function name (OnPanWin).
f. Click the Edit Code button and enter the following code:
/*set the location of the PanWindow*/
m_LEAD1.SetPanWinX(100.0f);
m_LEAD1.SetPanWinY(100.0f);
/*set the size of the PanWindow*/
m_LEAD1.SetPanWinWidth(150.0f);
m_LEAD1.SetPanWinHeight(200.0f);
/*set the type of mouse pointer*/
m_LEAD1.SetPanWinPointer(12);
m_LEAD1.SetPanWinTitle("PanWindow");
m_LEAD1.SetPanWinRectColor(RGB(0, 0, 255));
m_LEAD1.SetPanWinSysMenu(1);
/*use the settings for LEAD1*/
m_LEAD1.SetPanWinPaintPalette(m_LEAD1.GetPaintPalette());
m_LEAD1.SetPanWinBitonalScaling(m_LEAD1.GetBitonalScaling());
m_LEAD1.SetPanWinPaintScaling(m_LEAD1.GetPaintScaling());
m_LEAD1.SetPanWinPaintDither(m_LEAD1.GetPaintDither());
m_LEAD1.ShowPanWin(TRUE);
m_Check1.SetCheck(TRUE);
14. Add the following line to the OnInitDialog procedure in the PanDlg.cpp file, following : // TODO: Add extra initialization here
m_LEAD1.Load("v:\\images\\eagle.cmp", 0, 0, 1);
15. Press Ctrl-W to go to the MFC Class Wizard; then do the following:
a. Click the Message Maps tab.
b. In the Class Name combo box, select CPanDlg.
c. In the Object IDs list box, select IDC_LEAD1.
d. In the Messages list box, select OnPanWin.
e. Click the Add function button. Choose OK for the default function name (OnPanWin).
f. Click the Edit Code button and code the OnPanWin procedure as follows:
if (iFlag == PANWIN_DESTROYED)
{
m_Check1.SetCheck(FALSE);
}
16. On the main menu, select Build> Build pan.exe to build the project.
17. On the main menu, select Build> Execute pan.exe to run the project.