Using a PanWindow (Delphi 6.0)
1. |
Start with the project that you created in Loading and Displaying an Image. |
2. |
Replace the FormCreate Procedure with the following: |
procedure TForm1.FormCreate(Sender: TObject);
begin
//Set defaults for displaying the image.
//These are all persistent properties that can be set in the properties box.
LEADRasterView1.Appearance:= RASTERVIEW_APPEARANCE_FLAT;
LEADRasterView1.BorderStyle := 1;
LEADRasterView1.BackColor := RGB(255, 255, 125);
LEADRasterView1.PaintDither := PAINTDITHER_DIFFUSION;
LEADRasterView1.PaintPalette := PAINTPALETTE_AUTO;
LEADRasterView1.AutoRepaint := True;
LEADRasterView1.AutoSize := False;
LEADRasterView1.AutoSetRects := True;
LEADRasterView1.PaintSizeMode := PAINTSIZEMODE_NORMAL;
end;
3. |
Add a Check Box control to your form and set the Name and Caption properties as follows: |
|
|
Name |
Caption |
|
chkPanWin |
Pan Window |
4. |
Add a Button to the form and set the Name and Caption properties as follows: |
|
|
Name |
Caption |
|
btnPanWindow |
Show Pan Window |
5. |
Code the btnPanWindow click’s procedure as the following: |
procedure TForm1.btnPanWindowClick(Sender: TObject);
begin
With LEADRasterView1 do
begin
BackErase := False;
//set the location of the PanWindow
PanWinX := 100;
PanWinY := 100;
//set the size of the PanWindow
//requested width
PanWinWidth:= 150;
//requested height
PanWinHeight := 200;
LEADRasterView1.PanWinPointer:= 12;
PanWinTitle := 'PanWindow';
PanWinRectColor:= RGB(0, 0, 255);
PanWinSysMenu := True;
//use the settings for LEADRasterView1.
PanWinPaintPalette := PaintPalette;
PanWinBitonalScaling := BitonalScaling;
PanWinPaintScaling := PaintScaling;
PanWinPaintDither := PaintDither;
//show the Pan Window
ShowPanWin ( True );
end;
chkPanWin.Checked := True;
end;
6. |
Code the LEADRasterView1 OnPanWin event procedure as follows: |
procedure TForm1.LEADRasterView1PanWin(Sender: TObject; hPanWin: Integer;
iFlag: Smallint);
begin
if (iFlag = PANWIN_DESTROYED) then
chkPanWin.Checked := False ;//indicate no more Pan Window
end;
7. |
Run your program to test it. |