边框不见了,怎么回事
自定义函数drawitem, 用来自绘调用的。
结果边框看不见了,
边框是用Rectangle函数绘制
void DrawItem( DRAWITEMSTRUCT* item )
{
RECT rect;
if(!item)
return;
Rectangle(item->hDC, item->rcItem.left-1,item->rcItem.top-1,item->rcItem.top+1,item->rcItem.bottom+1);
SetBkMode(item->hDC,OPAQUE);
//内存dc法子
HBITMAP hBitmap=LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_BITMAP1));
HDC hMemDC=CreateCompatibleDC(item->hDC);
HBITMAP hOldBitmap=(HBITMAP)SelectObject(hMemDC,(HGDIOBJ)hBitmap);
BITMAP bitmap;
GetObject(hBitmap,sizeof(BITMAP),&bitmap);
StretchBlt(item->hDC,0,0,item->rcItem.right,item->rcItem.bottom,hMemDC,0,0,bitmap.bmWidth,bitmap.bmHeight,SRCCOPY);
SelectObject(hMemDC,hOldBitmap);
DeleteObject((HGDIOBJ)hBitmap);
DeleteObject((HGDIOBJ)hMemDC);
//
//Rectangle(item->hDC, item->rcItem.left-1,item->rcItem.top-1,item->rcItem.top+1,item->rcItem.bottom+1);
// Set the text color to gray if the button is selected.
if( item->itemState & ODS_SELECTED )
{
SetTextColor( item->hDC, RGB( 128, 128, 128 ) );//gray
}
else
{
SetTextColor( item->hDC, RGB( 255, 0, 0 ) );//red
}
// This will make the text move down and to the right when the button is
// pressed.
rect = item->rcItem;
if( item->itemState & ODS_SELECTED )
{
rect.top += 2;
rect.left += 2;
}
char title[256];
GetWindowText( item->hwndItem, title, sizeof( title ) );
DrawText( item->hDC, title, -1, &rect,
DT_CENTER | DT_VCENTER | DT_SINGLELINE );
}
[解决办法]
你把画边框的代码放到最后,否则可能被其它内容覆盖的。
[解决办法]
++。
Rectangle别用这个函数,它有填充色。
用FrameRect
[解决办法]
是不是被你后面的图片给盖住了~