hiding an mfc dialog based app 
Author Message
 hiding an mfc dialog based app

Hello,

I want to run a MFC dialog based app from my app but have it initially
hidden. I cannot find a way to do this. Any ideas?

TIA

IanM



Fri, 02 Jan 2004 23:01:45 GMT  
 hiding an mfc dialog based app

Quote:
>I want to run a mfc dialog based app from my app but have it initially
>hidden. I cannot find a way to do this. Any ideas?

Once again...

If you want the dialog to appear initially hidden here's a couple of
possibilities I've seen posted before:

Method 1
--------
Add a "visible" flag to the dialog class and initialize it to
FALSE in the constructor.

Add a handler for OnWindowPosChanging.

    void CTestDlg::OnWindowPosChanging( WINDOWPOS* lpwndpos )
    {
        if ( !m_bVisible )
            lpwndpos->flags &= ~SWP_SHOWWINDOW ;

        CDialog::OnWindowPosChanging(lpwndpos);
    }

Add a function to show/hide the app.

    void CTestDlg::DisplayWindow( BOOL bShow )
    {
        if ( bShow )
        {
            m_bVisible = TRUE;
            ShowWindow( SW_SHOWNORMAL );
        }
        else
        {
            m_bVisible = FALSE;
            ShowWindow( SW_HIDE );
        }
    }

Method 2
--------

Post a user defined message in OnInitDialog, and position the dialog
off-screen. In the processing of the user defined message hide the
window, and when you want to display it you can reposition
it and show it. Here's the general idea:

BEGIN_MESSAGE_MAP(CMindlgDlg, CDialog)
        //{{AFX_MSG_MAP(CMindlgDlg)
        ...
        //}}AFX_MSG_MAP
        ON_MESSAGE( WM_APP+1, OnAppMsg )
END_MESSAGE_MAP()

BOOL CMindlgDlg::OnInitDialog()
{
        ...

        // TODO: Add extra initialization here
        SetWindowPos( NULL, -1000, -1000, 0, 0,
                        SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE );

        PostMessage( WM_APP+1 );

        return TRUE;

Quote:
}

LRESULT CMindlgDlg::OnAppMsg(WPARAM, LPARAM)
{
        ShowWindow( SW_HIDE );
        return 0;

Quote:
}

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.


Sat, 03 Jan 2004 00:48:56 GMT  
 hiding an mfc dialog based app

Quote:

>I want to run a mfc dialog based app from my app but have it initially
>hidden. I cannot find a way to do this. Any ideas?

Convert to a modeless dialog. See here:

www.mooremvp.freeserve.co.uk/Win32/w32tip26.htm

--
Bob Moore [WinSDK MVP]
http://www.mooremvp.freeserve.co.uk/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Do not reply via email unless specifically requested to do so.
Unsolicited email is NOT welcome and will go unanswered.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Sat, 03 Jan 2004 07:01:46 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. HOWTO: hide dialog when a dialog-based app starts

2. Main dialog initially hidden, how? (mfc dialog app)

3. How to hide a messagebox before it pops up, in a dialog based app

4. Hide dialog based app on startup

5. PBM: Message box not displayed after main dialog box is closed in MFC dialog-based app

6. Hiding a dialog-based app

7. How can I tell when a dialog based app gets hidden or exposed

8. Hide dialog based apps

9. A: How to start dialog-based app hidden

10. Hiding a dialog based app on startup

11. cannot instantiate an activex control in mfc dialog based app

12. Problem using delete with dialog-based MFC app

 

 
Powered by phpBB® Forum Software