Click here to Skip to main content
15,897,291 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionEdit boxes Interaction Pin
swaapu7-Oct-05 1:32
swaapu7-Oct-05 1:32 
QuestionRe: Edit boxes Interaction Pin
David Crow7-Oct-05 3:15
David Crow7-Oct-05 3:15 
AnswerRe: Edit boxes Interaction Pin
swaapu7-Oct-05 19:23
swaapu7-Oct-05 19:23 
QuestionEdit boxes Interaction Pin
swaapu7-Oct-05 1:32
swaapu7-Oct-05 1:32 
QuestionDrawTextEx not working properly when printing on Windows 98 Pin
Paul Vickery7-Oct-05 1:24
professionalPaul Vickery7-Oct-05 1:24 
AnswerRe: DrawTextEx not working properly when printing on Windows 98 Pin
KaЯl7-Oct-05 1:54
KaЯl7-Oct-05 1:54 
AnswerRe: DrawTextEx not working properly when printing on Windows 98 Pin
Paul Vickery7-Oct-05 5:18
professionalPaul Vickery7-Oct-05 5:18 
GeneralRe: DrawTextEx not working properly when printing on Windows 98 Pin
KaЯl7-Oct-05 5:26
KaЯl7-Oct-05 5:26 
Paul S. Vickery wrote:
GetTextExtent/TextOut is all very well, but that doesn't tell me how much of my text will fit into a given rectangle
Yes, but not directly. GetTextExtent will give you the size required to draw the given text. Knowing where you begin to write the text, you should then be able to say if the text will go outside a given rectangle or not.
IMO? you should use it before drawing. Here's a sample how I use it:

CClientDC dc(this);

CFont *pFont = CFont::FromHandle((HFONT)::GetStockObject(DEFAULT_GUI_FONT));
CFont *pOldFont = dc.SelectObject(pFont);
CRect clientRect;
CSize textSize = dc.GetTextExtent(sTitle);

GetClientRect(&clientRect);
int iWidth = clientRect.Width() - 12; // keeping 6 pixels on each side of the text

CString strNewTitle(sTitle);

while(textSize.cx > iWidth){
    // the text is too big to fit: reduce it
    sTitle = sTitle.Left(sTitle.GetLength() - 1);
    strNewTitle = sTitle + _T("...");
    textSize = dc.GetTextExtent(strNewTitle);
}








The great error of nearly all studies of war has been to consider war as an episode in foreign policies, when it is an act of interior politics - Simone Weil
Fold with us! ¤ flickr

AnswerRe: DrawTextEx not working properly when printing on Windows 98 Pin
Paul Vickery7-Oct-05 5:43
professionalPaul Vickery7-Oct-05 5:43 
GeneralRe: DrawTextEx not working properly when printing on Windows 98 Pin
KaЯl7-Oct-05 6:05
KaЯl7-Oct-05 6:05 
GeneralRe: DrawTextEx not working properly when printing on Windows 98 Pin
Paul Vickery9-Oct-05 23:02
professionalPaul Vickery9-Oct-05 23:02 
GeneralRe: DrawTextEx not working properly when printing on Windows 98 Pin
KaЯl9-Oct-05 23:24
KaЯl9-Oct-05 23:24 
GeneralRe: DrawTextEx not working properly when printing on Windows 98 Pin
Jack Puppy7-Oct-05 14:33
Jack Puppy7-Oct-05 14:33 
GeneralRe: DrawTextEx not working properly when printing on Windows 98 Pin
Paul Vickery9-Oct-05 22:56
professionalPaul Vickery9-Oct-05 22:56 
Questiongetting the font name Pin
FarPointer7-Oct-05 1:15
FarPointer7-Oct-05 1:15 
AnswerRe: getting the font name Pin
KaЯl7-Oct-05 1:47
KaЯl7-Oct-05 1:47 
GeneralRe: getting the font name Pin
FarPointer7-Oct-05 5:54
FarPointer7-Oct-05 5:54 
QuestionAbout CDatabase : Plz Help : Urgent Pin
parims7-Oct-05 0:24
parims7-Oct-05 0:24 
QuestionRe: About CDatabase : Plz Help : Urgent Pin
David Crow7-Oct-05 3:19
David Crow7-Oct-05 3:19 
QuestionHow to Configure Windows Update Pin
Girish6017-Oct-05 0:16
Girish6017-Oct-05 0:16 
QuestionRe: How to Configure Windows Update Pin
David Crow7-Oct-05 3:34
David Crow7-Oct-05 3:34 
AnswerRe: How to Configure Windows Update Pin
Girish6017-Oct-05 20:09
Girish6017-Oct-05 20:09 
GeneralRe: How to Configure Windows Update Pin
David Crow10-Oct-05 2:56
David Crow10-Oct-05 2:56 
GeneralRe: How to Configure Windows Update Pin
Girish60110-Oct-05 4:23
Girish60110-Oct-05 4:23 
QuestionRe: How to Configure Windows Update Pin
David Crow10-Oct-05 4:30
David Crow10-Oct-05 4:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.