An application can simulate a press of the PRINTSCREEN key in order to obtain a screen snapshot and save it to the clipboard. To do this, call keybd_event with the bVk parameter set to VK_SNAPSHOT, and the bScan parameter set to 0 for a snapshot of the full screen or set bScan to 1 for a snapshot of the active window.
按print screen sys rp键,或发一个该建的消息
OpenClipboard(); // Reserve clipboard for this program // *************************************************************** // There are two alternative sources of bitmaps that this sample // can use. Choose either the 4 lines (next) that use "MyBitmap" // from the resource file, or the line below that which loads a // bitmap from a bitmap file. // Alternative 1: This code places a bitmap drawn by you in the // resource editor onto a button /* Remove the comment if you use this alternative CBitmap MyBitmap; MyBitmap.LoadBitmap(IDB_BITMAP1); // A Bitmap you drew in the // Resource Editor HBITMAP MyBitmapHandle = (HBITMAP)MyBitmap; // Cast it to a HBITMAP SetClipboardData(CF_BITMAP, MyBitmapHandle); */ //Remove the comment to use alternative 1. // End if alternative 1 // Alternative 2: This code places a bitmap from a file onto // the button. Comment it out if you use alternative 1 above. if(NULL==(SetClipboardData(CF_BITMAP, LoadImage(NULL, "C:\\Test.bmp", IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE|LR_LOADFROMFILE) ))) { AfxMessageBox("SetClipboardData returned a NULL"); }; // End of alternative 2 // End of alternatives // *************************************************************** CloseClipboard(); // Free clipboard so PasteFace() can use it
// There are two alternative sources of bitmaps that this sample
// can use. Choose either the 4 lines (next) that use "MyBitmap"
// from the resource file, or the line below that which loads a
// bitmap from a bitmap file.
// Alternative 1: This code places a bitmap drawn by you in the
// resource editor onto a button
/* Remove the comment if you use this alternative
CBitmap MyBitmap;
MyBitmap.LoadBitmap(IDB_BITMAP1); // A Bitmap you drew in the
// Resource Editor
HBITMAP MyBitmapHandle = (HBITMAP)MyBitmap; // Cast it to a HBITMAP
SetClipboardData(CF_BITMAP, MyBitmapHandle);
*/ //Remove the comment to use alternative 1.
// End if alternative 1
// Alternative 2: This code places a bitmap from a file onto
// the button. Comment it out if you use alternative 1 above.
if(NULL==(SetClipboardData(CF_BITMAP, LoadImage(NULL,
"C:\\Test.bmp", IMAGE_BITMAP, 0,
0, LR_DEFAULTSIZE|LR_LOADFROMFILE) )))
{
AfxMessageBox("SetClipboardData returned a NULL");
};
// End of alternative 2 // End of alternatives
// *************************************************************** CloseClipboard(); // Free clipboard so PasteFace() can use it