I am trying to size a checkbox so that it will fit on any text I load from my stringtable. 'pButton' is my checkbox in the code below.
I am finding that if I do a simple
CDC* pDC = pButton->GetDC();
pDC->SelectObject( pButton->GetFont() );
CString strScale( _T( "This is a long string" ) );
pButton->GetWindowRect( &rectRequired );
ScreenToClient( &rectRequired );
pDC->DrawText( strScale, rectRequired, DT_CALCRECT ); // Just calculate, dont draw the text
pButton->MoveWindow( &rectRequired );
pButton->SetWindowText( strScale );
The text is still not all being shown due to some of the 'rectRequired' being used for the actual checkbox itself.
I have tried using AdjustWindowRectEx but that makes no difference.
I tried what is suggested at http:Q_10248099.html
; adding on the width of the bitmap still gives a rectangle too small.
What do you think ?