win32 用多个画刷画FillRect矩形,多次拖拉窗口,会被白色覆盖,为什么?
for(inti=0;i<200;i++){FillRect(gdc,&rect[i],CreateSolidBrush(colorRef[i]));//矩形无边框Del...
for (int i = 0; i<200; i++)
{
FillRect(gdc, &rect[i], CreateSolidBrush(colorRef[i])); //矩形无边框
DeleteObject(CreateSolidBrush(colorRef[i]));
}
我试过用双缓冲也一样
这样可以啊,多次拖拉窗口重绘都没有问题,fillrect不用SelectObject不是可以吗,怎么样吖?
HBRUSH hBrush, hBrush0;
for (int i = 0; i<200; i++)
{
hBrush = CreateSolidBrush(colorRef[i]);
hBrush0 = SelectObject(gdc, hBrush);
FillRect(gdc, &rect[i], hBrush);
SelectObject(gdc, hBrush0);
//DeleteObject(SelectObject(gdc, GetStockObject(BLACK_BRUSH)));
//SelectObject(gdc, CreateSolidBrush(colorRef[0]));
//DeleteObject(SelectObject(hdc, GetStockObject(WHITE_BRUSH)));
//FillRect(gdc, &rect[i], CreateSolidBrush(colorRef[i]));
//DeleteObject(CreateSolidBrush(colorRef[i]));
DeleteObject(hBrush);
} 展开
{
FillRect(gdc, &rect[i], CreateSolidBrush(colorRef[i])); //矩形无边框
DeleteObject(CreateSolidBrush(colorRef[i]));
}
我试过用双缓冲也一样
这样可以啊,多次拖拉窗口重绘都没有问题,fillrect不用SelectObject不是可以吗,怎么样吖?
HBRUSH hBrush, hBrush0;
for (int i = 0; i<200; i++)
{
hBrush = CreateSolidBrush(colorRef[i]);
hBrush0 = SelectObject(gdc, hBrush);
FillRect(gdc, &rect[i], hBrush);
SelectObject(gdc, hBrush0);
//DeleteObject(SelectObject(gdc, GetStockObject(BLACK_BRUSH)));
//SelectObject(gdc, CreateSolidBrush(colorRef[0]));
//DeleteObject(SelectObject(hdc, GetStockObject(WHITE_BRUSH)));
//FillRect(gdc, &rect[i], CreateSolidBrush(colorRef[i]));
//DeleteObject(CreateSolidBrush(colorRef[i]));
DeleteObject(hBrush);
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询