if( !m_pControlDlg ) {
m_pControlDlg = new CControlDlg();
ASSERT( m_pControlDlg );
ASSERT( AfxIsValidAddress( m_pControlDlg ,
sizeof( CControlDlg ) ) );
bool bCreated = m_pControlDlg->Create( IDD_DIALOG_CONTROL, this );
ASSERT(bCreated);////this is where my failure occures
m_pControlDlg->ShowWindow( SW_SHOWNORMAL );
}
Any ideas?
I appreciate any ideas you could give.
Thanks.
Did your CControlDlg::OnInitDialog() and CControlDlg::OnCreate() get called?
Trace into the m_pControlDlg->Create() call and see what MFC is doing with
it.
-- David
Try a call to GetLastError() and see what you get.
According to the docs on the basic API's ::CreateWindow() function, the call
can fail for
- an invalid parameter value
- the system class was registered by a different module
- The WH_CBT hook is installed and returns a failure code
- if one of the controls in the dialog template is not registered, or its
window window procedure fails WM_CREATE or WM_NCCREATE
The last one sounds like it might be pertinent. Maybe your dialog is
hosting a child control that is failing its OnCreate() handler. Or maybe
your dialog is hosting a rich edit without a prior call to
AfxInitRichEdit().
As already pointed out, you have failed to tell us what ::GetLastError said, and you have
to find this out BEFORE the ASSERT happens (one of the bug reports I filed years ago and
which STILL has not been fixed is that ASSERT changes the ::GetLastError value, which is a
serious design error with ASSERT). So you have to set a breakpoint at the ASSERT
statement and look at the value
ERR,hr
in a watch window.
You can also set the no-fail-create style on the dialog and see if it creates; if it does,
some control is missing, and that's your problem.
joe
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
I tried GetLastError (never used it before)....I get the value of 0
and in the watch box I have:
@err,hr S_OK
@err 0x00000000
you can see where I added it below.
But I did tried the no-fail-create style in the dialog option and it
did go to the OnInitDialog, which it did not do before. So it
executed more of the code, but still did not show the dialog. So if
there is anymore insight on why the no-fail-create would allow more of
the code to be executed, but still not display that would appreciated.
if( !m_pControlDlg ) {
m_pControlDlg = new CControlDlg();
ASSERT( m_pControlDlg );
ASSERT( AfxIsValidAddress( m_pControlDlg ,
sizeof( CControlDlg ) ) );
bool bCreated = m_pControlDlg-
>Create( IDD_DIALOG_CONTROL, this );
DWORD error = GetLastError();///the value this returns
is 0
The OnInitDialog does not get called (unless I set no-fail-create
style), is that weird or better yet do you know why that would be? I
don't have a OnCreate() for my dialog, but there is one for the parent
dialog, so do I need one too? I have the constructor called and that
executes. I am working with existing stuff and only the main dialog
has a OnCreate.
Look if any other IDs are using the same number
as IDD_DIALOG_CONTROL have.
A simple test might be trying a different number ID for
for IDD_DIALOG_CONTROL ...
a simple try ...: bool bCreated = m_pControlDlg->Create( 777, this );
jmarc...
I found the issue I have a costum control box and it doesn't like
that....I need to investigate why...I am probably missing a
initialization of the costum box. So unless you know what that would
need to be, thanks for the help.
.. or it is related with 'this' ou pass to Create...
The class within your code is calling Create and passing 'this'
must be derived from a common base class somewhere in the
hiearchy.
If it is not, I supposed you should pass NULL instead of 'this'
bool bCreated = m_pControlDlg->Create( IDD_DIALOG_CONTROL, NULL);
jmarc...
So we now know where to look, but I don't know why ShowWindow doesn't work, unless you
have something else that is killing the dialog off.
joe
email: newc...@flounder.com