Re: What's happen? SetDlgItemText Crash
This function creates a dialog from a memory template.
This function sends a WM_INITDIALOG message to your dialog window class.
The function send to a WM_FONT message to the dialog. So look at your OnSetFond function of your dialog (if you have one).
Perhaps you could make a breakpoint in your
OnInitDialog or OnSetFont functions of your dialog class (the problem could be here).
To be complete the function shows the dialog if the WS_VISIBLE is set in the style's dialog box.
Do you have try to make step into the function ?
I am not sure of what does the SDK ::CreateDialogIndirect function. Perhaps it could assert the validity of the parent wnd.
Re: What's happen? SetDlgItemText Crash
The appli. displays my dialog box and i can see that it displays the content of some controls but just after it crashes.
I put a breakpoint in the OnInitDialog() function -i don't have a OnSetFont() function- , just before the CDialog::OnInitDialog() line. But it crashes before.I can't eter in the OnInitDialog funtion.
Step by step, i localize the crash: it occurs in the CDialog::DoModal() function, at this line
VERIFY(RunModalLoop(dwFlags) == m_nModalResult);
and in the RunModalLoop() function at this line:
// pump message, but quit on WM_QUIT
if (!AfxGetThread()->PumpMessage())
???
Re: What's happen? SetDlgItemText Crash
The appli. displays my dialog box but just after it crashes.
I put a breakpoint in the OnInitDialog() function -i don't have a OnSetFont() function- , just before the CDialog::OnInitDialog() line. But it crashes before.I can't eter in the OnInitDialog funtion.
Step by step, i localize the crash: it occurs in the CDialog::DoModal() function, at this line
VERIFY(RunModalLoop(dwFlags) == m_nModalResult);
and in the RunModalLoop() function at this line:
// pump message, but quit on WM_QUIT
if (!AfxGetThread()->PumpMessage()) // HERE
{
AfxPostQuitMessage(0);
return -1;
}
???
Re: What's happen? SetDlgItemText Crash
Dont know what exactly is your problem ?
I think the better way is to go back to a previous version that works.
Then add the portions little by little and try to found the source of your crash.
I look at the PumpMessage function.
It returns FALSE (and quit) if GetMessage returns FALSE that means if a WM_QUIT message is received.
Dont know where your problem comes from.
Re: What's happen? SetDlgItemText Crash
The last one...
I want to thank all, and in particular Eric33, for your attention and your advises. You spent a long time to help me to resolve my problem. It was very nice...
I think my problem comes really from the function SetDlgItemText(). When i set in comment all the calls to this function, the appli works almost: Step by step with the debugger, the dialog box is displayed but when you click on OK or Cancel it crashes (??). I have always the "access violation (NTDDLL.DLL) " message when i try to open some dialog boxes (those which crash).
But, at the end of month of June ( 99/09/26), i sent a mail to the forum to know how to use SetDlgItemText(). And, somabody explain me that use this function as many people advise me , that is to say format a CString variable with the numeric value and use SetDlgItemText(), is ill-advise. Cause the CString constructor allocates small amounts of memory on the heap and very often calls will make the heap fragmented. Is it perhaps the source of my problem?
I don't know... I will work with a backup and implement step by step the missing functions
Thank all very much
Sandrine
Re: What's happen? SetDlgItemText Crash
Using CString is not ill advise as the person said to you.
If you just declare a local CString or heap CString the problem is to correctly free up the cstring when you dont need it anymore. Dont forget that after setting the text with SetDlgItemText you can free your CString because the control has it own memory for text allocation.
I think that the method to go back to a previous good backup is good.
No matter how long it is to help you
Forums like codeguru are usefull only if it helps you founding a solution to your problems.
So dont bother and send questions if any