首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Windows Mobile >

windows mobile 出了一个奇怪的bug解决办法

2012-04-10 
windows mobile 出了一个奇怪的bug做了一个截屏的程序,在模拟器上仿真部署的时候没有任何错误,可是从程序

windows mobile 出了一个奇怪的bug
做了一个截屏的程序,在模拟器上仿真部署的时候没有任何错误,可是从程序生成的exe启动就会出错,为什么呢?代码如下:
HBITMAP CopyScreenToBitmap(LPRECT lpRect)
{
HDC hScrDC;
HDC hMemDC;
HBITMAP hBitmap,hOldBitmap;
int nX,nY,nX2,nY2;
int nWidth,nHeight;
int xScrn,yScrn;
if(IsRectEmpty(lpRect))
return NULL;
hScrDC = CreateDC(NULL,NULL,NULL,NULL);
hMemDC=CreateCompatibleDC(hScrDC);
nX=lpRect->left;
nY=lpRect->top;
nX2=lpRect->right;
nY2=lpRect->bottom;
xScrn=GetDeviceCaps(hScrDC,HORZRES);
yScrn=GetDeviceCaps(hScrDC,VERTRES);
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;
hBitmap=CreateCompatibleBitmap(hScrDC,nWidth,nHeight);
  hOldBitmap=(HBITMAP)SelectObject(hMemDC,hBitmap);
BitBlt(hMemDC,0,0,nWidth,nHeight,hScrDC,nX,nY,SRCCOPY);
hBitmap=(HBITMAP)SelectObject(hMemDC,hOldBitmap);
DeleteDC(hScrDC);
DeleteDC(hMemDC);
return hBitmap;
}
extern "C" __declspec(dllexport) HBITMAP WINAPI TakePhoto()
  {
LPRECT lpRect;
  lpRect->left=0;
  lpRect->top=40;
  lpRect->bottom=284;
  lpRect->right=240;

  HBITMAP hBitmap1=CopyScreenToBitmap(lpRect);
  return hBitmap1;
  }

[解决办法]
什么错误啊?
[解决办法]
C++不了解,c#的我已经实现了此功能,是在wince下验证过的。http://download.csdn.net/download/chainway765/3135218
[解决办法]
我这儿也有C# 在wince平台上截屏的源码呢 要的CALL我
[解决办法]
我觉得CREATEDC太多了。

热点排行