Capturing an Area (Visual C++ 5 and later)
Take the following steps to add some code that will let you capture a triangular area.
1. |
Start with the project you created in Capturing an Active Window. |
|
2. |
Add a command button and set the ID and Caption properties as follows: |
|
|
ID |
Caption |
|
IDC_CAPAREA |
Capture Area |
3. |
Press Ctrl-W to go to the MFC Class Wizard; then do the following: |
|
|
a. |
Click the Message Maps tab. |
|
b. |
In the Class Name combo box, select CScrCapDlg. |
|
c. |
In the Object IDs list box, select IDC_CAPAREA. |
|
d. |
In the Messages list box, select BN_CLICKED. |
|
e. |
Click the Add function button. Choose OK for the default function name (OnCaparea). |
|
f. |
Click the Edit Code button and code the OnCaparea procedure as follows: |
void CScrCapDlg::OnCaparea()
{
m_pLEADRasterScr->PutScaleMode (SCALEMODE_PIXEL);
//set up the info window
m_pLEADRasterScr->PutCaptureAreaShowInfoWindow (TRUE);
m_pLEADRasterScr->PutCaptureAreaInfoTop (0.0f);
m_pLEADRasterScr->PutCaptureAreaInfoLeft (0.0f);
m_pLEADRasterScr->PutCaptureAreaInfoHeight (300.0f);
m_pLEADRasterScr->PutCaptureAreaInfoWidth (300.0f);
//show area size and cursor information on an opaque background
m_pLEADRasterScr->PutCaptureAreaShowAreaSize (TRUE);
m_pLEADRasterScr->PutCaptureAreaShowCursorPosition (TRUE);
m_pLEADRasterScr->PutCaptureAreaShowOpaqueText (TRUE);
//set text colors, fill colors, fill pattern, and line style
m_pLEADRasterScr->PutCaptureAreaDrawLineColor (RGB(0, 0, 0));
m_pLEADRasterScr->PutCaptureAreaTextBackColor (RGB(0, 0, 255));
m_pLEADRasterScr->PutCaptureAreaTextForeColor (RGB(255, 255, 255));
m_pLEADRasterScr->PutCaptureAreaFillBackColor (RGB(255, 0, 0));
m_pLEADRasterScr->PutCaptureAreaFillForeColor (RGB(0, 0, 255));
m_pLEADRasterScr->PutCaptureAreaFillPattern (CAPTURE_AREA_PATTERN_CROSS);
m_pLEADRasterScr->PutCaptureAreaDrawLineStyle (CAPTURE_AREA_LINE_DASH);|
//do not include the cursor in the image
m_pLEADRasterScr->PutCaptureAreaIncludeCursor (FALSE);
//do not enable the keyboard
m_pLEADRasterScr->PutCaptureAreaEnableKeyboard (FALSE);
//save a bitmap with a region
m_pLEADRasterScr->PutCaptureAreaBitmapWithRegion (TRUE);
//make the info window sensitive to the position of the cursor
m_pLEADRasterScr->PutCaptureAreaSensitiveInfoWindow (TRUE);
//zoom the image in the info window
m_pLEADRasterScr->PutCaptureAreaZoomFactor (CAPTURE_AREA_ZOOM_BY2X);
//use the cross lines cursor instead of the CaptureAreaDrawCursorIndex
m_pLEADRasterScr->PutCaptureAreaUseCrossLinesCursor(TRUE);
m_pLEADRasterScr->PutCaptureAreaShowDrawCursor (TRUE);
//capture a triangular area
m_pLEADRasterScr->CaptureArea (SCR_CAP_AREA_TRIANGLE);
//assign the Screen Capture Control bitmap to the Main Control bitmap
m_LEADRasterView1.GetRaster().SetBitmap(m_pLEADRasterScr->GetBitmap ());
}
4. |
On the main menu, select Build> Build ScrCap.exe to build the project. |
5. |
On the main menu, select Build> Execute ScrCap.exe to run the project. Click on Capture Area, press F11, and click and drag to select the area to capture. |