Click here to Skip to main content
16,011,447 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: string formatting Pin
Todd Smith19-Sep-02 7:00
Todd Smith19-Sep-02 7:00 
GeneralRe: string formatting Pin
jamiehale19-Sep-02 7:46
jamiehale19-Sep-02 7:46 
GeneralRe: string formatting Pin
Michael Dunn19-Sep-02 7:59
sitebuilderMichael Dunn19-Sep-02 7:59 
GeneralDoModal() and CDialog caption Pin
ns19-Sep-02 4:36
ns19-Sep-02 4:36 
GeneralRe: DoModal() and CDialog caption Pin
TyMatthews19-Sep-02 4:46
TyMatthews19-Sep-02 4:46 
GeneralThanks! Pin
ns19-Sep-02 4:51
ns19-Sep-02 4:51 
GeneralRe: DoModal() and CDialog caption Pin
ns19-Sep-02 5:08
ns19-Sep-02 5:08 
GeneralRe: DoModal() and CDialog caption Pin
TyMatthews19-Sep-02 5:27
TyMatthews19-Sep-02 5:27 
Yeah, this is the same as calling SetWindowText() directly. You can't do it either way because your window doesn't exist yet. You have to squirrel away the variable for use later on, once the window does exist.

You can always call other functions of CTest, just not any that deal with windows Smile | :) Which pretty much limits you to DoModal() and anything you've written yourself.

Here's what is really happening under the hood. SetWindowText() is an immediate action that needs to occur. This is also an MFC-specific function in CWnd. MFC handles this particular action by sending a low-level windows message, likely via the SendMessage() API call, named WM_SETTEXT. SendMessage() only works when you specify a valid handle to a pre-existing window. Your window doesn't exist yet, so this parameter would be NULL.

If you called SendMessage() yourself with a NULL parameter, the result is probably undefined. It likely just goes nowhere. MFC is protecting you from this unfortunate situation by kicking out an ASSERT and gently reminding you that you can't do this yet. SetWindowText and the many other MFC functions of CWnd are just protective wrappers around the Win32 API. If you didn't get this ASSERT, you'd never know that your caption wasn't being set properly, and you'd be looking all over the place trying to figure out why. God bless MFC Poke tongue | ;-P

Hope this helps-


Ty


"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein


GeneralRe: DoModal() and CDialog caption Pin
ns19-Sep-02 8:21
ns19-Sep-02 8:21 
GeneralRe: DoModal() and CDialog caption Pin
Maximilien19-Sep-02 5:37
Maximilien19-Sep-02 5:37 
GeneralRe: DoModal() and CDialog caption Pin
ns19-Sep-02 8:18
ns19-Sep-02 8:18 
GeneralVolatile variable... Pin
Anonymous19-Sep-02 4:40
Anonymous19-Sep-02 4:40 
GeneralRe: Volatile variable... Pin
TyMatthews19-Sep-02 4:50
TyMatthews19-Sep-02 4:50 
GeneralRe: Volatile variable... Pin
Raphael Kindt19-Sep-02 5:31
Raphael Kindt19-Sep-02 5:31 
GeneralRe: Volatile variable... Pin
Michael Dunn19-Sep-02 5:44
sitebuilderMichael Dunn19-Sep-02 5:44 
GeneralRe: Volatile variable... Pin
Raphael Kindt19-Sep-02 5:58
Raphael Kindt19-Sep-02 5:58 
GeneralPreTranslateMessage return value Pin
ns19-Sep-02 4:20
ns19-Sep-02 4:20 
GeneralRe: PreTranslateMessage return value Pin
dazinith19-Sep-02 4:34
dazinith19-Sep-02 4:34 
Generalfile permissions check and cleanup Pin
dazinith19-Sep-02 4:14
dazinith19-Sep-02 4:14 
GeneralRe: file permissions check and cleanup Pin
TyMatthews19-Sep-02 5:11
TyMatthews19-Sep-02 5:11 
GeneralRe: file permissions check and cleanup Pin
dazinith19-Sep-02 5:46
dazinith19-Sep-02 5:46 
GeneralRe: file permissions check and cleanup Pin
TyMatthews19-Sep-02 5:50
TyMatthews19-Sep-02 5:50 
GeneralProblem running *.exe file without debug mode Pin
saekth19-Sep-02 3:45
saekth19-Sep-02 3:45 
GeneralRe: Problem running *.exe file without debug mode Pin
Nitron19-Sep-02 4:04
Nitron19-Sep-02 4:04 
GeneralRe: Problem running *.exe file without debug mode Pin
saekth19-Sep-02 4:19
saekth19-Sep-02 4:19 

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.