Re: Need help resolving modeless dialog issue



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
****

Thanks,
~Scoots
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: Attachment windows open behind active window
    ... Without knowing his settings for IE, ... Also would depend on the type of attachment, i.e., is he launching another ... >I have a senior citizen who has told me verbally that, when he opens an ... >a new window, but the window is behind all windows on the desktop. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: Window Size in Windows Mail
    ... Next time follow the given directions the first time around. ... Gary VanderMolen, MS-MVP (Mail) ... It opens in a small window. ...
    (microsoft.public.windows.vista.mail)
  • Re: Checkpoint Securemote CLIENT Crashes
    ... Try to launch client application for first time. ... Not even a window that appears. ... icon opens the window, where you can create your remote site. ... SecureClient also creates two services that you can check to see if they ...
    (comp.security.firewalls)
  • NIC properties window fails to open
    ... remember if anyone needs help just ask bob ... >window opens, fails to populate, and closes. ... This is the first time I have ever seen this ...
    (microsoft.public.win2000.advanced_server)
  • Re: cant open drive C directly
    ... This is not the first time that I have done this. ... The weird thing is that now if I want to open the Drive C, or USB memories from My Computers they dont open. ... Instead a window opens asking me to choose a program from the list!!. ... If I click on the icon for the local disk the "open with" window appears. ...
    (microsoft.public.windowsxp.hardware)