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

C / C++ / MFC

 
GeneralRe: Memory Managment Pin
c_sisbit17-Jul-02 3:47
c_sisbit17-Jul-02 3:47 
GeneralRe: Memory Managment Pin
Joaquín M López Muñoz17-Jul-02 3:50
Joaquín M López Muñoz17-Jul-02 3:50 
GeneralRe: Memory Managment Pin
c_sisbit17-Jul-02 3:59
c_sisbit17-Jul-02 3:59 
GeneralRe: Memory Managment Pin
includeh1017-Jul-02 4:17
includeh1017-Jul-02 4:17 
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 
Sorry for the formatting, I can't seem to find the instructions on how to correctly format source code in these messages.

All I'm trying to do is have the title bar text of a SDI application have the usual title plus some right justified text (szReg). I was not able to do it using the CMainFrame OnPaint, so I tried to fudge it by adding spaces between the two strings until the extent of the text was about enough to fill the window width. I think I will need to take into consideration the border size later, but this code doesn't really get it very close. The text ends up quite a bit short of where I wanted it to be. (This is all done in my own UpdateFrameTitleForDocument()).

Thanks.

//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
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 
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 

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.