Click here to Skip to main content
15,911,030 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Memory Managment Pin
Joaquín M López Muñoz17-Jul-02 5:00
Joaquín M López Muñoz17-Jul-02 5:00 
GeneralRe: Memory Managment Pin
cc_sisbit17-Jul-02 20:35
cc_sisbit17-Jul-02 20:35 
GeneralBooks For Sale! Pin
jamiehale17-Jul-02 3:01
jamiehale17-Jul-02 3:01 
QuestionGetTextExtent? Should be simple? Pin
Anonymous17-Jul-02 3:00
Anonymous17-Jul-02 3:00 
AnswerRe: GetTextExtent? Should be simple? Pin
Philippe Mori17-Jul-02 3:14
Philippe Mori17-Jul-02 3:14 
GeneralRe: GetTextExtent? Should be simple? Pin
Dave_17-Jul-02 4:13
Dave_17-Jul-02 4:13 
GeneralRe: GetTextExtent? Should be simple? Pin
Scott H. Settlemier17-Jul-02 6:10
Scott H. Settlemier17-Jul-02 6:10 
AnswerRe: GetTextExtent? Should be simple? Pin
Jason Henderson17-Jul-02 3:19
Jason Henderson17-Jul-02 3:19 
Use <pre> tags.

C++
//The code --

CString szTitle = szText;

TRY{
	CWindowDC dc(this);
	CRect r;
	GetWindowRect(&r); 
	int nWindWidth = r.Width();
	int nSpace = nWindWidth;

	szTitle += szReg;

	//Acutal width of the title string
	int nActualWidth = dc.GetTextExtent(szTitle).cx;
	BOOL bStop = FALSE;
	CString szSep;
	int nCount = 0;

	//keep looping until the width of the window
	//is taken up by the string. Add spaces between
	//the normal title, and the new (right justified)
	//text I'm adding:
	while (!bStop){
		if (nActualWidth < nSpace){
			//Not filled up yet, keep adding spaces
			//between the strings:
			szSep += " ";
			szTitle = szText + szSep + szReg;
			nActualWidth = dc.GetTextExtent(szTitle).cx;
		}
		else
			bStop = TRUE;
		
		nCount++;
		if (nCount > 1000){
			//this should not happen
			bStop = TRUE;
			SetWindowText(szText + " " + szReg); 
		}
	}
	
	SetWindowText(szTitle);
}
CATCH(CResourceException,e){
	SetWindowText(szText + " " + szReg);
}
END_CATCH 


Jason Henderson
quasi-homepage
articles
"Like it or not, I'm right!"


GeneralActiveMovie4 Pin
Anonymous17-Jul-02 2:52
Anonymous17-Jul-02 2:52 
GeneralVT_ARRAY | VT_UI1 Pin
Hans Ruck17-Jul-02 2:24
Hans Ruck17-Jul-02 2:24 
GeneralRe: VT_ARRAY | VT_UI1 Pin
Anonymous17-Jul-02 2:33
Anonymous17-Jul-02 2:33 
QuestionHow to insert text to CStdioFile??? Pin
Raphael Kindt17-Jul-02 2:22
Raphael Kindt17-Jul-02 2:22 
AnswerRe: How to insert text to CStdioFile??? Pin
Joaquín M López Muñoz17-Jul-02 2:50
Joaquín M López Muñoz17-Jul-02 2:50 
Generalno luck with changing text on toplevel menu Pin
ns17-Jul-02 1:26
ns17-Jul-02 1:26 
GeneralRe: no luck with changing text on toplevel menu Pin
567890123417-Jul-02 3:02
567890123417-Jul-02 3:02 
GeneralWoW! Thank you!!!!! Pin
ns17-Jul-02 3:11
ns17-Jul-02 3:11 
GeneralImplementing Windows->Close All Menu option in MDI application using VC++/MFC Pin
Binoy17-Jul-02 1:25
Binoy17-Jul-02 1:25 
GeneralRe: Implementing Windows->Close All Menu option in MDI application using VC++/MFC Pin
Joaquín M López Muñoz17-Jul-02 3:15
Joaquín M López Muñoz17-Jul-02 3:15 
GeneralRe: Implementing Windows->Close All Menu option in MDI application using VC++/MFC Pin
Binoy21-Jul-02 18:44
Binoy21-Jul-02 18:44 
GeneralWindow Region and Placement Pin
Dov Sherman17-Jul-02 0:08
Dov Sherman17-Jul-02 0:08 
GeneralRe: Window Region and Placement Pin
Joaquín M López Muñoz17-Jul-02 2:21
Joaquín M López Muñoz17-Jul-02 2:21 
GeneralRe: Window Region and Placement Pin
Dov Sherman17-Jul-02 2:47
Dov Sherman17-Jul-02 2:47 
GeneralRe: Window Region and Placement Pin
Joaquín M López Muñoz17-Jul-02 2:58
Joaquín M López Muñoz17-Jul-02 2:58 
GeneralRe: Window Region and Placement Pin
Dov Sherman17-Jul-02 4:58
Dov Sherman17-Jul-02 4:58 
GeneralRe: Window Region and Placement Pin
Joaquín M López Muñoz17-Jul-02 5:09
Joaquín M López Muñoz17-Jul-02 5:09 

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.