Using a PanWindow (C++ Builder 4.0)
1. |
Start with the project that you created in Loading and Displaying an Image. |
2. |
Replace the Main Form Create Procedure to the follwing. |
void __fastcall TForm1::FormCreate(TObject *Sender)
{
//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
= (TColor)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;
}
3. |
Add a RadioButton to the form and set the Name and Caption properties as follows: |
|
|
Name |
Caption |
|
Check1 |
Pan Window |
4. |
Add a Button to the form and set the Name and Caption properties as follows: |
|
|
Name |
Caption |
|
PanWindow |
Show Pan Window |
5. |
Code the PanWindow click’s procedure as the following: |
void __fastcall TForm1::PanWindowClick(TObject *Sender)
{
LEADRasterView1->BackErase
= False;
//set the location of the PanWindow
LEADRasterView1->PanWinX
= 100;
LEADRasterView1->PanWinY
= 100;
//set the size of the PanWindow
//requested width
LEADRasterView1->PanWinWidth
= 150;
//requested height
LEADRasterView1->PanWinHeight
= 200;
LEADRasterView1->PanWinPointer
= 12;
LEADRasterView1->PanWinTitle
= "PanWindow";
LEADRasterView1->PanWinRectColor
= (TColor)RGB(0, 0, 255);
LEADRasterView1->PanWinSysMenu
= True;
//use the settings for LEADRasterView1.
LEADRasterView1->PanWinPaintPalette
= LEADRasterView1->PaintPalette;
LEADRasterView1->PanWinBitonalScaling
= LEADRasterView1->BitonalScaling;
LEADRasterView1->PanWinPaintScaling
= LEADRasterView1->PaintScaling;
LEADRasterView1->PanWinPaintDither
= LEADRasterView1->PaintDither;
//show the Pan Window
LEADRasterView1->ShowPanWin
(True);
Check1->Checked= True;
}
6. |
Code the LEADRasterView1 PanWin event procedure as follows: |
void __fastcall TForm1::LEADRasterView1PanWin(TObject
*Sender,
long hPanWin, short iFlag)
{
if (iFlag == PANWIN_DESTROYED)
Check1->Checked= False ;//indicate no more Pan Window
}
7. |
Run your program to test it. |