当滚动时,我写了一个死循环 while(GetKeyState(VK_RIGHT) < 0) { BitBlt(....) } 此时,可达到要求,CPU 占用率%100 但无法获得WINDOWS message,I need the GetKeyState() But in the 死循环,It doesn't work, 如何完善这个循环
我现在用的就是OnTimer() {} 看看这个吧:滚动时,我写了一个死循环 while(GetKeyState(VK_RIGHT) < 0) { BitBlt(....) } 此时,可达到要求,CPU 占用率%100 但无法获得WINDOWS message,I need the GetKeyState() But in the 死循环,It doesn't work, 如何完善这个循环 使GetKeyState() work
玉米:用这个函数. int SetDIBitsToDevice( HDC hdc, // handle to DC int XDest, // x-coord of destination upper-left corner int YDest, // y-coord of destination upper-left corner DWORD dwWidth, // source rectangle width DWORD dwHeight, // source rectangle height int XSrc, // x-coord of source lower-left corner int YSrc, // y-coord of source lower-left corner UINT uStartScan, // first scan line in array UINT cScanLines, // number of scan lines CONST VOID *lpvBits, // array of DIB bits CONST BITMAPINFO *lpbmi, // bitmap information UINT fuColorUse // RGB or palette indexes );
code_cold(玉米) (2001-11-28 17:21:00) 得0分 当滚动时,我写了一个死循环 while(GetKeyState(VK_RIGHT) < 0) { BitBlt(....) } 此时,可达到要求,CPU 占用率%100 但无法获得WINDOWS message,I need the GetKeyState() But in the 死循环,It doesn't work, 如何完善这个循环 我来回答你这个问题: 在while循环中加入下面代码就行了 MSG msg; while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); :
硬件不差(G400,32M)
几个DC都可,BitBlt到CClientDC dc(this)
你的妹儿。 我的是[email protected]
[email protected]
即使是普通的视,也可以滚动啊。
while(GetKeyState(VK_RIGHT) < 0) {
BitBlt(....)
}
此时,可达到要求,CPU 占用率%100
但无法获得WINDOWS message,I need the GetKeyState()
But in the 死循环,It doesn't work,
如何完善这个循环
看看这个吧:滚动时,我写了一个死循环
while(GetKeyState(VK_RIGHT) < 0) {
BitBlt(....)
}
此时,可达到要求,CPU 占用率%100
但无法获得WINDOWS message,I need the GetKeyState()
But in the 死循环,It doesn't work,
如何完善这个循环
使GetKeyState() work
试一试吧!
因为不太清楚 HDC,HBITMAP的机制,所以你试一下:
申请一块内存缓冲(恐怕要50M了), GetBitmapBits将位图数据读入,(lpmem为缓冲指针),
另外申请一块内存,lpmem2(就是窗口显示数据了),CopyMemory将lpmem中的需要数据读入lpmem2, SetBitmapBits将lpmem2的数据写入窗口显示区。
不过,你有那么大的数据量速度是一定会受影响的。
int SetDIBitsToDevice(
HDC hdc, // handle to DC
int XDest, // x-coord of destination upper-left corner
int YDest, // y-coord of destination upper-left corner
DWORD dwWidth, // source rectangle width
DWORD dwHeight, // source rectangle height
int XSrc, // x-coord of source lower-left corner
int YSrc, // y-coord of source lower-left corner
UINT uStartScan, // first scan line in array
UINT cScanLines, // number of scan lines
CONST VOID *lpvBits, // array of DIB bits
CONST BITMAPINFO *lpbmi, // bitmap information
UINT fuColorUse // RGB or palette indexes
);
当滚动时,我写了一个死循环
while(GetKeyState(VK_RIGHT) < 0) {
BitBlt(....)
}
此时,可达到要求,CPU 占用率%100
但无法获得WINDOWS message,I need the GetKeyState()
But in the 死循环,It doesn't work,
如何完善这个循环
我来回答你这个问题:
在while循环中加入下面代码就行了
MSG msg; while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
:
在OnDraw(CDC* pDC)或OnPaint()函数中用Bitblt刷新需刷新区域.应该是能自动处理的,如果不行的话就自已用编码实现,刷新区域在CPaintDC->m_ps.rcPaint中,是一个CRect.
我以前编过一个程序那怕是10000*10000的图像基本也能流畅的滚动,不过我用的是DIB位图,用SetDIBitsToDevice函拷贝到屏幕的。