
Changing text in dialog box
Quote:
> I implemented the dialog box the way that you suggested. It compiles fine, but
> i get a run time error. When i run the de{*filter*} it shows the error at the
> arrow:
> CWnd *CWnd::GetDlgItem(int nID) const
> {
> --> ASSERT(::IsWindow(m_hWnd));
> if(m_pCtrl==NULL)
> ....
> At first i had the call to GetDlgItem inside the menu class, and thought that
> there might be problems accessing the variables of the dialog class. Then i put
> the call inside a function for the dialog class, and the same problem remained.
> I used this same GetDlgItem function in other places in this program and it has
> always worked. if you have any suggestions of where i could start to look for
> the problem, it would be helpful.
> Thank,
> jess
It is necessary, but not sufficient, to put the call inside the dialog
class. The m_hWnd that the ASSERT checks is the HWND of the dialog.
The ASSERT is telling you that the dialog window has not yet been
created. Of course, that means that whatever control you are accessing
has not yet been created either. You can only access controls on a
dialog after the DoModal call. Not before DoModal, and not in the
dialog constructor. The place to do such things is in the OnInitDialog
function after it calls the CDialog base class.
--
Scott McPhillips [VC++ MVP]