|
Did you ask before that you can only use ActiveX. Because of security issues, the web does not allow this feature (security sandbox), ActiveX can be achieved, so ActiveX security is widely criticized.
The following is the key code of ActiveX written in VC ++, it should be easier to use C #, but the client does not know whether it is necessary to install Framework to run ActiveX.
HBITMAP CCopyScr :: CopyToBmp (CRect Rect)
{
// Screen and memory device description table
HDC hScrDC, hMemDC;
// Bitmap handle
HBITMAP hBitmap, hOldBitmap;
// Coordinates of the selected area
int nX, nY, nX2, nY2;
// Bitmap width and height
int nWidth, nHeight;
// Screen Resolution
int xScrn, yScrn;
// Make sure the selected area is not empty rectangle
if (IsRectEmpty (&Rect))
return NULL;
// Create a device description table for the screen
hScrDC = CreateDC ("DISPLAY", NULL, NULL, NULL);
The
// Create a compatible memory device description table for the screen device description table
hMemDC = CreateCompatibleDC (hScrDC);
The
// Get the coordinates of the selected area
nX = Rect.left;
nY = Rect.top;
nX2 = Rect.right;
nY2 = Rect.bottom;
The
// get screen resolution
xScrn = GetDeviceCaps (hScrDC, HORZRES);
yScrn = GetDeviceCaps (hScrDC, VERTRES);
The
// Make sure the selected area is visible
if (nX <0)
nX = 0;
if (nY <0)
nY = 0;
if (nX2> xScrn)
nX2 = xScrn;
if (nY2> yScrn)
nY2 = yScrn;
nWidth = nX2-nX;
nHeight = nY2-nY;
The
// Create a bitmap compatible with the screen device description table
hBitmap = CreateCompatibleBitmap (hScrDC, nWidth, nHeight);
The
// Select the new bitmap to the memory device description table
hOldBitmap = (HBITMAP) SelectObject (hMemDC, hBitmap);
The
// Copy the screen device description table to the memory device description table
BitBlt (hMemDC, 0, 0, nWidth, nHeight, hScrDC, nX, nY, SRCCOPY);
The
// Get the handle of the screen bitmap
hBitmap = (HBITMAP) SelectObject (hMemDC, hOldBitmap);
The
// Clear
DeleteDC (hScrDC);
DeleteDC (hMemDC);
The
// return the bitmap handle
return hBitmap;
} |
|