the control have the WS_TRANSPARENT style. and:
case WM_ERASEBKGND:
{
return TRUE;
}
break;
case WM_CTLCOLORSTATIC:
{
return (LRESULT)GetStockObject(NULL_BRUSH);
}
break;
case WM_DRAWITEM:
{
DRAWITEMSTRUCT *test=(DRAWITEMSTRUCT*) lParam;
image imglabel(test->rcItem.right-test->rcItem.left,test->rcItem.bottom-test->rcItem.top);
if(inst->blnTransparent!=true)
FillRect(test->hDC,&test->rcItem, CreateSolidBrush(inst->clrBackColor));
else
FillRect(test->hDC,&test->rcItem,(HBRUSH) GetStockObject(NULL_BRUSH));
FillRect(imglabel,&test->rcItem,CreateSolidBrush(inst->clrBackColor));
if(inst->imgtest.haveimage())
DrawHICONtoHDC(imglabel, inst->imgtest,1,1);
SetBkMode(imglabel,TRANSPARENT);
char *text=(char*)inst->strCaption.c_str();
SetTextColor(imglabel,inst->clrTextColor );
DrawTextEx(imglabel,text,-1,&test->rcItem,DT_LEFT,NULL);
if(inst->blnBorder==true)
DrawEdge(imglabel, &test->rcItem,BDR_SUNKENINNER | BDR_RAISEDOUTER,BF_RECT);
imglabel.Backcolor=inst->clrBackColor;
TransparentBlt(test->hDC,0,0,test->rcItem.right,test->rcItem.bottom,imglabel,0,0,test->rcItem.right,test->rcItem.bottom, inst->clrBackColor);
return TRUE;
}
break;
these code is what show us the label transparent.
now with click i did these:
case BN_CLICKED:
{
HDC Hdc=GetDC(inst->hwnd);
POINT curpos;
GetCursorPos(&curpos);
ScreenToClient(inst->hwnd,&curpos);
if(GetPixel(Hdc,curpos.x ,curpos.x)!=CLR_INVALID && inst->blnTransparent==true)
inst->MouseClick();
else if(inst->blnTransparent==false)
inst->MouseClick();
ReleaseDC(inst->hwnd,Hdc);
}
break;
(my label is the win32 button class)
when the control is transparent the pixel(backcolor) isn't showed. but how can i test that pixels?
that code works, but it's instable(works sometimes) :(