Hide dialog based app on startup 
Author Message
 Hide dialog based app on startup

Can anyone tell me how you hide a dialog based app as soon as it starts?
(App generated with the wizard). I thought just changing the dialog
properties and unchecking visible would be the kiddie but alas no... I've
also tried various things with ShowWindow in OnInitDialog with about as much
luck as an unlucky thing.

Cheers for any help -

Tim.



Mon, 05 Jul 2004 20:11:25 GMT  
 Hide dialog based app on startup
Try unchecking the visible flag for your dialog in the resource view.


Quote:
> Can anyone tell me how you hide a dialog based app as soon as it starts?
> (App generated with the wizard). I thought just changing the dialog
> properties and unchecking visible would be the kiddie but alas no... I've
> also tried various things with ShowWindow in OnInitDialog with about as
much
> luck as an unlucky thing.

> Cheers for any help -

> Tim.



Tue, 06 Jul 2004 22:48:41 GMT  
 Hide dialog based app on startup
See Bob's tip at

        http://www.mooremvp.freeserve.co.uk/Win32/framed_tip026.htm

Cheers
Check Abdoul
-------------------


Quote:
> Can anyone tell me how you hide a dialog based app as soon as it starts?
> (App generated with the wizard). I thought just changing the dialog
> properties and unchecking visible would be the kiddie but alas no... I've
> also tried various things with ShowWindow in OnInitDialog with about as
much
> luck as an unlucky thing.

> Cheers for any help -

> Tim.



Tue, 06 Jul 2004 23:22:06 GMT  
 Hide dialog based app on startup

Quote:
>Can anyone tell me how you hide a dialog based app as soon as it starts?

Tim,

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.


Wed, 07 Jul 2004 00:49:30 GMT  
 Hide dialog based app on startup
Thanks for the tips guys, I'll try them out later today :o)

Tim.



Fri, 09 Jul 2004 18:58:59 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Hiding a dialog based app on startup

2. How to create a Dialog based Application with MainDlg hidden on startup

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

4. Question on Dialog based app startup

5. Again: minimizing dialog-based app on startup....

6. Dialog based app minimize on startup???/

7. hiding an mfc dialog based app

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

9. Hiding a dialog-based app

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

11. Hide dialog based apps

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

 

 
Powered by phpBB® Forum Software