Re: Modeless Dialog Issues.
- From: "leov SpamMeNot" <lviolette.SpamMeNot@xxxxxxxxxx>
- Date: Wed, 28 Sep 2005 15:47:02 -0700
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.
>
>
>
.
- References:
- Modeless Dialog Issues.
- From: leov SpamMeNot
- Modeless Dialog Issues.
- Prev by Date: Re: changing tool tip at runtime
- Next by Date: compose bmp file
- Previous by thread: Modeless Dialog Issues.
- Next by thread: Re: Modeless Dialog Issues.
- Index(es):
Relevant Pages
|