KeyPress example for C++ Builder
This example demonstrates the KeyPress event.
//This example uses the KeyPress event to implement a custom scale mode.
//There is no particular reason to put this code in this event
//This sample is just here to provide an example of both the Key Press event
//and the scale mode.
void __fastcall TForm1::LEADRasterView1KeyPress (TObject *Sender,
short KeyAscii)
{
if (KeyAscii == 67) //Uppercase C
{
//This example sets an custom scale mode and uses it to crop the
//display. Keep in mind that the actual height and width do not change.
//Only the unit of measure changes.
//Change the scale so that origin is moved one-third right and one-third down
LEADRasterView1->ScaleLeft = -1;
LEADRasterView1->ScaleTop = -1;
LEADRasterView1->ScaleWidth = 3;
LEADRasterView1->ScaleHeight = 3;
//Crop the display so that it takes up the middle third of the height and width
LEADRasterView1->DstClipLeft = 0;
LEADRasterView1->DstClipTop = 0;
LEADRasterView1->DstClipWidth = 1;
LEADRasterView1->DstClipHeight = 1;
LEADRasterView1->ForceRepaint ();
}
}