Click here to Skip to main content
15,916,188 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: uh-oh...ON_COMMAND_RANGE Pin
Joaquín M López Muñoz4-Feb-03 9:16
Joaquín M López Muñoz4-Feb-03 9:16 
GeneralRe: uh-oh...ON_COMMAND_RANGE Pin
ns4-Feb-03 9:21
ns4-Feb-03 9:21 
Generaltrouble! Pin
ns4-Feb-03 9:20
ns4-Feb-03 9:20 
GeneralRe: trouble! Pin
Joaquín M López Muñoz4-Feb-03 9:34
Joaquín M López Muñoz4-Feb-03 9:34 
GeneralRe: trouble! Pin
ns4-Feb-03 10:31
ns4-Feb-03 10:31 
GeneralMRU FILE LIST Pin
tsb4-Feb-03 8:46
tsb4-Feb-03 8:46 
GeneralRe: MRU FILE LIST Pin
Ind5-Feb-03 2:43
Ind5-Feb-03 2:43 
GeneralGetTextExtentPoint32 Pin
Dave_4-Feb-03 8:35
Dave_4-Feb-03 8:35 
I am trying to something that should be very simple. I am filling a CStatic with text until the GetTextExtentPoint32 function returns a width close to the width of the CStatic.

The end result is that the CStatic has much more room than what GetTextExtentPoint32 is saying the string width will be.Mad | :mad:

Is there something else I need to do?

The loop ends when it determines that the newSize.cx will be greater than the nWidth (determined by GetWindowRect()). The string returned is much smaller than the width of the window (nWidth). (nMargin = 2).

(Sorry about the tabs, I thought the code button might deal with it)

Thank you!!

SIZE newSize;<br />
			::GetTextExtentPoint32(hDC,szNew,szNew.GetLength(),&newSize);<br />
			if (newSize.cx < (nWidth + nMargin)){<br />
				//new string smaller than width<br />
				int nIns = 1;<br />
				while (!bFound && (nIns <= szMid.GetLength())){<br />
					CString szInsert = szMid.Right(nIns++);<br />
					szNew.Format("%s\\...%s\\%s",szDir,szInsert,szFile);<br />
					::GetTextExtentPoint32(hDC,szNew,szNew.GetLength(),&newSize);<br />
					if (newSize.cx >= (nWidth + nMargin)){<br />
						bFound = TRUE;<br />
						szRet = szNew;<br />
					}<br />
				}<br />
			}

GeneralRe: GetTextExtentPoint32 Pin
Anders Molin4-Feb-03 12:05
professionalAnders Molin4-Feb-03 12:05 
GeneralRe: GetTextExtentPoint32 Pin
Dave_5-Feb-03 1:45
Dave_5-Feb-03 1:45 
GeneralRe: GetTextExtentPoint32 Pin
Chris Richardson4-Feb-03 18:00
Chris Richardson4-Feb-03 18:00 
GeneralRe: GetTextExtentPoint32 Pin
Dave_5-Feb-03 1:43
Dave_5-Feb-03 1:43 
GeneralStrange characters appearing in C++ email programme Pin
trimtrom4-Feb-03 8:34
trimtrom4-Feb-03 8:34 
GeneralRe: Strange characters appearing in C++ email programme Pin
Anders Molin4-Feb-03 11:57
professionalAnders Molin4-Feb-03 11:57 
QuestionHyperlinks in dialog apps ? Pin
autekre4-Feb-03 8:20
autekre4-Feb-03 8:20 
AnswerRe: Hyperlinks in dialog apps ? Pin
Joaquín M López Muñoz4-Feb-03 8:35
Joaquín M López Muñoz4-Feb-03 8:35 
Generalini files Pin
scara4-Feb-03 8:12
scara4-Feb-03 8:12 
GeneralRe: ini files Pin
Nitron4-Feb-03 11:13
Nitron4-Feb-03 11:13 
GeneralRe: ini files Pin
scara4-Feb-03 19:04
scara4-Feb-03 19:04 
GeneralRe: ini files Pin
Dave_5-Feb-03 1:50
Dave_5-Feb-03 1:50 
GeneralRS232 vs RS422 Pin
peter ho4-Feb-03 7:42
peter ho4-Feb-03 7:42 
GeneralRe: RS232 vs RS422 Pin
Tim Smith4-Feb-03 8:30
Tim Smith4-Feb-03 8:30 
GeneralThat sucks.. Pin
LiquidKnight4-Feb-03 7:36
LiquidKnight4-Feb-03 7:36 
GeneralRe: That sucks.. Pin
Rickard Andersson204-Feb-03 7:52
Rickard Andersson204-Feb-03 7:52 
GeneralRe: That sucks.. Pin
LiquidKnight4-Feb-03 7:55
LiquidKnight4-Feb-03 7:55 

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.