呼唤worldy
worldy ,你在12楼说textout可以往内存dc上写文字的。
原帖子:
http://bbs.csdn.net/topics/390320867
//透明背景
HDC hMemDC=CreateCompatibleDC(item->hDC);
HBITMAP hOldBitmap=(HBITMAP)SelectObject(hMemDC,(HGDIOBJ)hBitmap);
TextOut(hMemDC,0,0,"hello",strlen("hello"));//不管用,你说这里管用的! 我不会是用法出错了吧
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);
FrameRect(item->hDC,&(item->rcItem),(HBRUSH)GetStockObject(BLACK_BRUSH));
// Set the text color to gray if the button is selected.
if( item->itemState & ODS_SELECTED )
{
SetTextColor( item->hDC, RGB( 128, 128, 128 ) );
}
else
{
SetTextColor( item->hDC, RGB( 255, 0, 0 ) );
}
// 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 += 20;
rect.left += 20;
}
char title[256];
GetWindowText( item->hwndItem, title, sizeof( title ) );
DrawText( item->hDC, title, -1, &rect,
DT_CENTER | DT_VCENTER | DT_SINGLELINE );