本站首页    管理页面    写新日志    退出


«July 2025»
12345
6789101112
13141516171819
20212223242526
2728293031


公告

谦卑,荣誉,牺牲,英勇,怜悯,诚实,精神,公正。


我的分类(专题)

日志更新

最新评论

留言板

链接

 

 


Blog信息
blog名称:
日志总数:183
评论数量:698
留言数量:7
访问次数:3016675
建立时间:2005年12月29日




[编程学习]capture
读书笔记

newqiang 发表于 2006/1/9 11:00:01

HWND hwnd = ::FindWindow(NULL, "RobotSoccer"); if (hwnd == NULL)  return;  // get window size RECT r; ::GetWindowRect(hwnd,&r);  int xScreen,yScreen; //check if the window is out of the screen or maximixed <Qiang> int xshift = 0, yshift = 0; xScreen = GetSystemMetrics(SM_CXSCREEN); yScreen = GetSystemMetrics(SM_CYSCREEN); if(r.right > xScreen)  r.right = xScreen; if(r.bottom > yScreen)  r.bottom = yScreen; if(r.left < 0) {  xshift = -r.left;  r.left = 0; } if(r.top < 0) {  yshift = -r.top;  r.top = 0; }  SIZE sz; sz.cx = r.right - r.left; sz.cy = r.bottom - r.top;  if(sz.cx <= 0 || sz.cy <= 0) return;  // bring the window at the top most level ::SetWindowPos(hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);  // prepare the DCs HDC dstDC = ::GetDC(NULL); HDC srcDC = ::GetWindowDC(hwnd); //full window (::GetDC(hwnd); = clientarea) HDC memDC = ::CreateCompatibleDC(dstDC);  // copy the screen to the bitmap HBITMAP bm =::CreateCompatibleBitmap(dstDC, sz.cx, sz.cy); HBITMAP oldbm = (HBITMAP)::SelectObject(memDC,bm); ::BitBlt(memDC, 0, 0, sz.cx, sz.cy, srcDC, xshift, yshift, SRCCOPY);  // restore the position ::SetWindowPos(hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);  CxImage *newima = new CxImage(); newima->CreateFromHBITMAP(bm); char strFileName[10]; sprintf(strFileName, "c:\\%d.jpg", m_nTimer/10); newima->Save(strFileName, CXIMAGE_FORMAT_JPG); // free objects DeleteObject(SelectObject(memDC,oldbm)); DeleteObject(memDC);


阅读全文(3591) | 回复(0) | 编辑 | 精华
 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.031 second(s), page refreshed 144753417 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号