Using a PanWindow (Delphi 4.0)

1. Start Delphi 4.0.

2. On the Delphi toolbar, click the ActiveX tab, if one is present. If you have not added any ActiveX controls, there will not be an ActiveX tab present. If you have used a LEAD ActiveX control before, the icon appears on the toolbar. If no ActiveX controls are present, or if this control is not present, add the LEAD control as follows:

a. On the Component menu, choose Import ActiveX Control.

b. In the Import ActiveX dialog box, highlight the LEAD Main Control (12). Change the Class name to TLEAD. Click the Install button.

c. In the Install dialog, click OK.

d. In the Confirm dialog, click Yes. You will also see the Compiling package dclusr40 dialog confirming that dclusr40 will be compiled. Click Yes.

e. After compilation has finished, click OK in the Information dialog.

f. At this point you will be presented with the dclusr40.pas window, with a Contains folder. Within this folder are LEAD .dcr and .pas files. Save the dclusr40 project.

3. In the File menu, choose New Application.

4. Select the LEAD control on the ActiveX toolbar. Size and position the control as you want it to appear at run time, and change the name of the control to LEAD1.

5. Add a command button from the Standard toolbar to your form and name it as follows:

Name

Caption

PanWindow

Show Pan Window

6. Add a Check box from the Standard toolbar to the form and name it as follows:

Name

Caption

Check1

Pan Window

7. In the Project menu, choose Add to Project and add the LEADDEF.PAS file.

8. Select the Unit1 tab in the editor window. On the File menu, select Use Unit. Highlight LEADDEF and select OK.

9. Double click on the Show Pan Window button and code the PanWindowClick procedure as follows:

procedure TForm1.PanWindowClick(Sender: TObject);
begin
 with LEAD1 do
begin
     {set the location of the PanWindow}
     PanWinX := 100;
     PanWinY := 100;
     {set the size of the PanWindow}
     PanWinWidth := 150;
     PanWinHeight := 200;
     {set the type of mouse pointer}
     PanWinPointer := 12;

     PanWinTitle := 'PanWindow';
     PanWinRectColor := RGB(0, 0, 255);
     PanWinSysMenu := True;
     {use the settings for LEAD1}
     PanWinPaintPalette := PaintPalette;
     PanWinBitonalScaling := BitonalScaling;
     PanWinPaintDither := PaintDither;
     ShowPanWin(True);
end;
    Check1.Checked := True;
end;

10. Code the FormActivate procedure as follows:

procedure TForm1.FormActivate(Sender: TObject);
begin
       {set the paht and name to an image file on your system}
       LEAD1.Load ('e:\ltwin12x\images\image1.cmp', 0, 0, 1);
end;

11. Code the Lead1PanWin procedure as follows:

procedure TForm1.Lead1PanWin(Sender: TObject; hPanWin: Integer; iFlag: Smallint);
begin
    if (iFlag = PANWIN_DESTROYED) Then
        Check1.Checked := False;
end;

12. Run your program to test it.