Available in the LEADTOOLS Imaging toolkit. |
KeyPress example for C++ 4.0 and later
Note: This example failed during testing, because MFC 4.0 did not pass the KeyPress event. However the ScaleMode code inside the if statement will work if you use it in another event, such as a command button's click event.
VOID COcxtestDlg::Lead1_OnKeyPress(short FAR * KeyAscii)
{
// This is example uses the KeyPress event to implement a custom scale mode.
// There is no particular reason to put this code in this event, except that
// we needed examples of both the event and the scale mode.
if (*KeyAscii == 67) // Uppercase C
{
// This example sets a 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
m_Lead1.SetScaleLeft(-1.0f);
m_Lead1.SetScaleTop(-1.0f);
m_Lead1.SetScaleWidth(3.0f);
m_Lead1.SetScaleHeight(3.0f);
// Crop the display so that it takes up the middle third of the height and width
m_Lead1.SetDstClipLeft(0.0f);
m_Lead1.SetDstClipTop(0.0f);
m_Lead1.SetDstClipWidth(1.0f);
m_Lead1.SetDstClipHeight(1.0f);
m_Lead1.ForceRepaint();
}
}