Re: Modeless Dialog Issues.

Tech-Archive recommends: Fix windows errors by optimizing your registry



Thanks for the input.

As for the PreTranslateMessage calling IsDialogMessage. You indicated that
I should
be doing that in the modeless dialog. Is that instead of the main
application window doing
it or in addition to the main application window doing it?

In other words, should the Should the IsDialogMessage(...) preside in both
CMainFrame::PreTranslateMessage and CMyModelessDlg::PreTranslateMessage() or
just CMyModelessDlg::PreTranslateMessage()?

to the MainFrm
"AliR" <AliR@xxxxxxxxxxxxx> wrote in message
news:433b12d1$1_3@xxxxxxxxxxxxxxxxxxxxx
> "leov SpamMeNot" <lviolette.SpamMeNot@xxxxxxxxxx> wrote in message
> news:O9oNGqGxFHA.736@xxxxxxxxxxxxxxxxxxxxxxx
>> Okay, I created a modeless dialog and didn't like that it was forced to
>> be
>> in front of my main app. So...
>> I used GetDesktopWindow() as the parent. I know, this is bad. Perhaps
>> someone can recommend and alternative that gives me the same
> functionality.
>
> Not nessessarly bad. Your main application is also a child of the
> desktop.
> So if you want to get your new window and the main app window to be at the
> same level you have to make both of them be the child of the same window.
> You could have a hidden window of your own be the parent of both the main
> app window and the child dialog, but I think that is too much work if you
> don't need it
>
>> What is irking me now is that if I open the dialog and then switch to my
>> main application window and close it by selecting the X in the upper left
>> hand corner, the modeless dialog no longer automatically gets a WM_CLOSE
>> message posted to it. So, I end up with a memory leak.
>
> Your memory leak is most likely due to the way you create your Modeless
> dialog.
> The reason I am saying this is that because CDialogs destructor will close
> the window. So somehow your dialogs destructor is not being called.
>
> If you are doing something like this:
>
> CMyDlg *pDlg = new CMyDlg;
> pDlg->Create(CMyDlg::IDD,GetDesktopWindow());
> pDlg->ShowWindow(SW_SHOW);
>
> you will have a memory leak
>
> if you make the dialog variable a member of your CMainFrame or CView class
> then you should not have any problems.
>
> class CMainFrame : public CMDIFrameWnd
> {
> private:
> CMyDlg m_MyDlg;
> };
>
> int CMainFrame::OnCreate(...)
> {
>
> m_MyDlg.Create(CMyDlg::IDD,GetDesktopWindow());
> m_MyDlg.ShowWindow();
>
> }
>
> You should put the IsDialogMessage in the PreTranslateMessage of the
> Modeless dialog box
>
> BOOL CMyDlg::PreTranslateMessage( msg )
> {
> if( IsDialogMessage( msg ) )
> return TRUE;
>
> return CWnd::PreTranslateMessage( msg );
> }
>
>
> AliR.
>
>
>


.



Relevant Pages

  • Re: modeless dialog
    ... had nothing to do with modeless dialogs, and in fact the entire question was completely ... What you need is the window handle for the window in the ... >unlike in previous renditions of Windows, that permission must be granted by ... Joseph M. Newcomer [MVP] ...
    (microsoft.public.vc.mfc)
  • Memory trashing when I try to make a modal CDialog modeless
    ... But I want to make it modeless. ... ColDef(int order, wstring type, wstring value, bool ... memory window watching the first 135 bytes at metaRow. ...
    (microsoft.public.vc.mfc)
  • Re: Memory trashing when I try to make a modal CDialog modeless
    ... But I want to make it modeless. ... ColDef(int order, wstring type, wstring value, bool ... memory window watching the first 135 bytes at metaRow. ...
    (microsoft.public.vc.mfc)
  • Re: Modeless Dialog Issues.
    ... >and there will be no memory leak. ... if you leave the modeless dialog open and instead close the Main ... That's because it isn't owned by the app. ... >the modeless window was active. ...
    (microsoft.public.vc.mfc)
  • Re: Modeless Dialog Issues.
    ... In main app, whne calling m_pMyModelessDlg->Create, I pass ... and there will be no memory leak. ... if you leave the modeless dialog open and instead close the Main ... the modeless window was active. ...
    (microsoft.public.vc.mfc)