我用CSplitterWnd分了主窗口后,然后在每个视中画图做界面用,可这个程序占用CPU达到98%,不是为什么?
解决方案 »
- vs2008或2010“添加新数据源”出现的问题
- (急)vs2008 MFC问题
- 那位能说说使用AddRef 和 Release的体会?
- 急! error lnk2001:unresolved external symbol"public: int _thiscall CDllClass::Load(char const *)"错误
- 怎样在每一个对话框里的状态栏里显示一个自定义的indicators?
- 关于控件的问题,不知道选那种控件可以实现?
- 如何卸载我远程注入的dll?
- 怎样用钩子函数钩到一个Edit上?
- 各位大哥好,请问在vb中怎么把鼠标设置为沙漏形,然后又怎么恢复
- 关于动态创建的控件的字体设定问题!
- 大家来救救我吧,明天就要交作业了
- 如何在程序中使EDIT框不能继续输入文字
{
//Is the filename loaded
if(!IsFileLoaded)
{
MessageBox(NULL,"The filename of bitmap has not been loaded!","ERROR",MB_OK|MB_ICONERROR);
return;
}
//To open the bitmap file
CFile file;
if(!file.Open("Bmps/"+FileName,CFile::modeRead,NULL))
{
MessageBox(NULL,"Can not open the bitmap file!","ERROR",MB_OK|MB_ICONERROR);
return;
}
//To read the BITMAPFILEHEADER
BITMAPFILEHEADER bfHeader;
if(file.Read((void*)&bfHeader,sizeof(BITMAPFILEHEADER))!=sizeof(BITMAPFILEHEADER))
{
MessageBox(NULL,"Can not read the BITMAPFILEHEADER!","ERROR",MB_OK|MB_ICONERROR);
file.Close();
return;
}
//To read the BITMAPINFOHEADER
BITMAPINFOHEADER biHeader;
if(file.Read((void*)&biHeader,sizeof(BITMAPINFOHEADER))!=sizeof(BITMAPINFOHEADER))
{
MessageBox(NULL,"Can not read the BITMAPINFOHEADER!","ERROR",MB_OK|MB_ICONERROR);
file.Close();
return;
}
//Calculate the colors
int nColors=0;
if(biHeader.biBitCount<24) //if the RGBQUAD is in the data file
{
nColors=1<<biHeader.biBitCount;
}
//Contribute the memory for the new BITMAPINFO
BITMAPINFO* pBi;
pBi=(BITMAPINFO*) new BYTE[sizeof(BITMAPINFOHEADER)+nColors*sizeof(RGBQUAD)];
memcpy(pBi,&biHeader,sizeof(BITMAPINFOHEADER));
//Read the RGBQUAD
RGBQUAD* pQuad;
pQuad=(RGBQUAD*)((BYTE*)pBi+sizeof(BITMAPINFOHEADER));
if(file.Read((void*)pQuad,nColors*sizeof(RGBQUAD))!=nColors*sizeof(RGBQUAD))
{
MessageBox(NULL,"Can not read the RGBQUAD!","ERROR",MB_OK|MB_ICONERROR);
file.Close();
return;
}
//Read the image data
void* pImageData;
biHeader.biSizeImage=bfHeader.bfSize-bfHeader.bfOffBits;
pImageData=(void*) new BYTE[biHeader.biSizeImage];
if(file.Read(pImageData,biHeader.biSizeImage)!=biHeader.biSizeImage)
{
MessageBox(NULL,"Can not read the IMAGE DATA!","ERROR",MB_OK|MB_ICONERROR);
file.Close();
return;
}
//Draw the picture
//From: Scan start line
//To: Line to Scan to
SetDIBitsToDevice(pDC->GetSafeHdc(),Left,Top,biHeader.biWidth,biHeader.biHeight,
0,0,From,To,pImageData,pBi,DIB_RGB_COLORS);
//Close the file and release the memory
file.Close();
delete pBi;
delete pImageData;
}