Re: Need help resolving modeless dialog issue
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Mon, 30 Jul 2007 20:27:04 -0400
On Mon, 30 Jul 2007 13:32:41 -0700, Scoots <linkingfire@xxxxxxx> wrote:
Hi,*****
I have a weird problem that only shows up in a release build, and not
in debug. I have a modeless dialog I'm launching from a menu. It
opens up fine in debug mode, works great and while it needs tinkering,
it's fine.
I run into problems on a release build, though. The first time I
click to launch the dialog window (which runs this code:)
CPrgEditorDialog* dlg = new CPrgEditorDialog;
dlg->ptrToMain = m_hWnd;
dlg->ShowWindow(SW_SHOW);
You did not actually create a dialog here. You created a new instance of the C++ object,
but not an instance of the dialog itself.
You should do
dlg->Create(CPrgEditorDlg::IDD, this);
Note that by specifying 'this', you make the parent be the current window, so you don't
need ot have a ptrToMain (and if you DID have a ptrToMain, why is it an HWND instead of
being a CWnd * and write
dlg->ptrToMain = this;
since an HWND is not a ptr, and therefore using HN incorrectly is both misleading and a
source of future errors.
In the dialog, if you need to communicate to the window, you can write
GetParent()->SendMessage(...);
instead of
::SendMessage(ptrToMain, ...);
****
*****
The modeless dialog doesn't show up. If I navigate through the menu
and select it again, it opens correctly. Any attempts after that open
a new window on the first try.
You have not shown enough code to make it clear what happens if you call it a second time;
you only showed the code that handles it for the first time. You would need to show all
relevant code for the creation.
****
****
It's just like that first one gets fried as soon as I open it, but
only in release mode. I'll be happy to tell you more, I know this is
slight information to go on... but I don't know where to even begin
looking on this one.
See my essay on Surviving the Release Version in my MVP Tips site.
joe
****
Joseph M. Newcomer [MVP]
Thanks,
~Scoots
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- Need help resolving modeless dialog issue
- From: Scoots
- Need help resolving modeless dialog issue
- Prev by Date: Re: memory leak?
- Next by Date: Re: Need help resolving modeless dialog issue
- Previous by thread: Re: Need help resolving modeless dialog issue
- Index(es):
Relevant Pages
|