win32 - about DrawTextEx() and RECT

Started by
0 comments, last by cambalinho 9 years ago

the RECT with DrawTextEx() is make me confused sad.png

see these code:


RECT b={test.rcPaint.left+2, test.rcPaint.top, test.rcPaint.right-2, test.rcPaint.bottom};
imglabel.DrawText(inst->strCaption, b);

now see the DrawText(), on image class:


void DrawText(string strText,RECT HDCrect)
    {
        char *text=(char*)strText.c_str();
        DrawTextEx(HBitmap,text,-1,&HDCrect,DT_LEFT,NULL);
        //HBitmap is my BitmapDC class that can return HBITMAP and HDC
    }

by some reason, i can't use the top=0 and Left=1. because interfere with the Region results with HBITMAP.

can anyone explain to me the diference bettwen the PAINTSTRUCT hdc and the memory HDC?

(maybe is there the problem for not use the top=0 and Left=1)

Advertisement

the problem was resolved:


void DrawText(string strText,int PosX=0, int PosY=0)
    {
        char *text=(char*)strText.c_str();
        RECT b={0};
        b.left=PosX;
        b.right=imageweight;
        b.top=PosY;
        b.bottom=imageheight;
        DrawTextEx(HBitmap,text,strlen(text),&b,DT_LEFT ,NULL);
    }

destroying the old Region before the new Region:


TransparentBlt(test.hdc,0,0,imglabel.width(),imglabel.height(),imglabel,0,0, imglabel.width(),imglabel.height(), inst->clrBackColor);
SetWindowRgn(inst->hwnd,NULL,TRUE);

inst->LabelRegion=RegionbyBitmap(imglabel, inst->clrBackColor);
SetWindowRgn(inst->hwnd,inst->LabelRegion,TRUE);

This topic is closed to new replies.

Advertisement