高仿黄金首饰批发市场:windows编程中粘贴位图时for语句的疑惑

来源:百度文库 编辑:高考问答 时间:2024/05/08 10:26:36
程序在“hello world”程序上修改,在winmain函数中导入位图,把WM_PAINT消息处理改为 case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
int i;
hdc = GetDC(hWnd);
hMemDc = CreateCompatibleDC(hdc);
SelectObject(hMemDc,hsmile);
for(i=0;i<320;i+20)
{
BitBlt(hdc,i,0,20,20,hMemDc,0,0,SRCCOPY);
}
DeleteDC(hMemDc);
ReleaseDC(hWnd,hdc);
EndPaint(hWnd, &ps);
break;
编译后出现warning C4552: '+' : operator has no effect; expected operator with side-effect
也能运行,但只显示一幅位图。若把for语句改为
for(i=0;i<16;i++)
{
BitBlt(hdc,20*i,0,20,20,hMemDc,0,0,SRCCOPY);
}
则可正确显示为16幅位图一字排开。不知何故,望高手指点

i+20这个是没有意义的For。可以写成
for(i=0;i<320;i=i+20)

多看看书吧!!!!