Click to See Complete Forum and Search --> : OnInitDialog problem


May 21st, 1999, 11:13 AM
Hi,

Can you help me solve this problem?

I have two dialogs. From the first dialog class, I create an instance of the second dialog and call DoModal() (this happens when user clicks a button).

The problem is that the first function called by MFC in the second dialog's class is DoDataExchange(), not OnInitDialog() ! The following ASSERT() fails :

HWND CDataExchange::PrepareCtrl(int nIDC)
{
ASSERT(nIDC != 0);
ASSERT(nIDC != -1); // not allowed
HWND hWndCtrl;
m_pDlgWnd->GetDlgItem(nIDC, &hWndCtrl);
if (hWndCtrl == NULL)
{
TRACE1("Error: no data exchange control with ID 0x%04X.\n", nIDC);
ASSERT(FALSE); //THIS ONE FAILS.

Then some of the OnChange....() message handlers are called, which is bizarre.

Does anybody know why OnInitDialog() isn't being called straight away ?


Thanks,
Gaz.

zakaib
May 21st, 1999, 12:56 PM
You can find out which control its complaining about by running in the debugger, just before it asserts, it outputs a line telling you the Control ID it's having problems with. Then you can look in your resources.h file to see what control its confused about. It's basically telling you that there is an ID number with no associated control.

You probably have some mismatch between your resources.rc and resources.h file.

Dan