Sign in to follow this  
cambalinho

win32 - about DrawTextEx() and RECT

Recommended Posts

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)

Share this post


Link to post
Share on other sites

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);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this