Joeri,
You can only use this once the underlying dialog has been created and
attached to the CDialog class - the usual place to do this would be in
the dialog's OnInitDialog handler.
Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.
Dave, hope you're still here, cause im fucked up until i solve this problem, and
my work is due for monday morning(university task)
Joeri,
.
c_MyEditControl.SetWindowText("Whatever");
See my essays about Avoiding GetDlgItem and Avoiding UpdateData. You
should never have to touch GetSafeHandle or see an HWND. Note that you
cannot under any circumstances call SetWindowText either before, or
GetWindowText after, the DoModal, a common error.
joe
On Sat, 6 Jan 2001 06:52:03 -0800, "joeri" <jjur...@yahoo.com>
wrote:
>
>can you put a sample code of how to do it, ive been messing with GetSafeHandle()
>etc a long time, so if you just could tell me the keywords to get a handle to the
>dialog...
>if it has to be done like you said in OnInitDialog...
>BOOL CAboutDlg::OnInitDialog()
>{
> CDialog::OnInitDialog();
>
> ?????
> return TRUE;
>}
>
>Dave, hope you're still here, cause im fucked up until i solve this problem, and
>my work is due for monday morning(university task)
>
>-----Original Message-----
>>> whenever one opens a modal dialog(like the about dialog) and you try to
>>> use the function
>>> SetWindowText("Hello") on it, it gives a ASSERTION failure. It appears
>>> the dialog deosnt have a handle (hWnd) which it needs to perform this
>>> function. Can anyone please tell me how to overcome this problem.
>
>Joeri,
>
>You can only use this once the underlying dialog has been created and
>attached to the CDialog class - the usual place to do this would be in
>the dialog's OnInitDialog handler.
>
>Dave
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm
What if you have a CString variable 'str' that you want put in the
SetWindowText? F.ex.:
c_MyEditControl.SetWindowText(str);
The variable 'str' is not remembered by the program in OnInitDialog.
So my question is: how do you bring a long variables from one dialog to
another, to SetWindowText in the OnInitDialog??
Terje Karlsen
Sent via Deja.com
http://www.deja.com/
Terje,
Add a public CString member to your dialog class, eg.
CString m_text;
Then set it before you call DoModal, or in the constructor.
MyDialg dlg;
dlg m_text = "Hello";
dlg.DoModal();
Then do the SetWindowText in OnInitDialog
Jonno
> Terje,
> Add a public CString member to your dialog class, eg.
> CString m_text;
>
> Then set it before you call DoModal, or in the constructor.
>
> MyDialg dlg;
> dlg m_text = "Hello";
> dlg.DoModal();
>
> Then do the SetWindowText in OnInitDialog
> Jonno
>
Thanks!!
It worked!