Posted on 2012-10-16 09:45
盛勝 閱讀(497)
評論(0) 編輯 收藏 引用
來源:http://topic.csdn.net/u/20080228/14/8a514245-266e-4c58-9626-4ddeb52f0d97.html
1.截屏
2.建立一個無邊框的窗口,填充整個屏幕
3.將截屏內(nèi)容貼到窗口中
4.處理鼠標鍵盤消息即可
BOOL BitBlt(
HDC hdcDest, // handle to destination DC
int nXDest, // x-coord of destination upper-left corner
int nYDest, // y-coord of destination upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
HDC hdcSrc, // handle to source DC
int nXSrc, // x-coordinate of source upper-left corner
int nYSrc, // y-coordinate of source upper-left corner
DWORD dwRop // raster operation code
);
這個函數(shù)截取一個矩形很方便
無非就是處理鼠標按下和彈起消息,記錄下矩形框,調(diào)用BitBlt即可,當然效果好點還要動態(tài)繪制鼠標選中的矩形區(qū)域
提示:
HDC hDCForm, hdcScreen,hdcCompatible;
HBITMAP hbmScreen;
hDCForm=GetDC(Form1->Handle);
hdcScreen = CreateDC("DISPLAY", NULL, NULL, NULL);
hdcCompatible = CreateCompatibleDC(hdcScreen);
hbmScreen = CreateCompatibleBitmap(hdcScreen,
GetDeviceCaps(hdcScreen, HORZRES),
GetDeviceCaps(hdcScreen, VERTRES));
if(!SelectObject(hdcCompatible, hbmScreen))
{
ShowMessage("erro!");
}
BitBlt(hdcCompatible,
0,0,
800, 600,
hdcScreen,
0,0,
SRCCOPY);