Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » CExtLabel derived request Collapse All
Subject Author Date
Offer Har Mar 2, 2009 - 11:37 AM

Dear Support,


I have a CExtLabel derived class, in which I want to know the exact size of the text in the control, so that I can add my drawing after the text.


The way to do it is by using DT_CALCRECT as you well know. I tried to pass to OnDrawLabelText all the parameters including DT_CALCRECT, and I see that the internal rc there gets the right size (these are the last line of the function):


 


...

CRect rc( rcText );     rc.DeflateRect( &m_rcLabelTextMargins );     dc.DrawText(         LPCTSTR(strText),         int(_tcslen(strText)),         rc,         dwDrawTextFlags         );     dc.SetTextColor( clrOldText );     dc.SetBkMode( nOldBkMode );     if( hFont != NULL )         ::SelectObject( dc, hOldFont ); }


My problem is that this rc is local, so I cannot get this value... for now what I did was duplicate OnDrawLabelTextinto my derived, and made it return this rc of the actual size of the text.


Is is possible for next version that this function, which return void now, will return this size?


Many thanks,


Ron.

Technical Support Mar 3, 2009 - 12:04 PM

We guess you are discussing a simple text label control with left aligned text. In this case it’s possible even to design some new virtual methods in the CExtLabel class for measuring and painting additional content near the text. But labels can be center aligned, right aligned, single line, multi line and even bitmap based. So, approach should be definitively different. Please provide us with more details about your task so we can improve the CExtLabel class.

Offer Har Mar 3, 2009 - 12:09 PM

Dear Support,


The requirement I have is that there will be a line extending after the text all the way to the end of the label box (in the right theme of-course), like this:



I derived from CExtLabel, and added the line, but you are right, I did not add implementation for centered text etc.


I think that this is a nice feature - if you can add it to the coming version it’ll be handy for more library users.


Thanks,


Ron.


 

Torsten Schucht Nov 2, 2009 - 9:57 AM

Thanks for the fix. It works just fine!!