Can I start a dialog app initially hidden? 
Author Message
 Can I start a dialog app initially hidden?

I need to write a dialog app that starts out initially hidden. Is there any
other way besides creating a normal hidden window and calling DoModal from
there? Windows seems to ignore the fact that I don't have a WS_VISIBLE flag
set.

Gil Rosin



Mon, 25 Sep 2000 03:00:00 GMT  
 Can I start a dialog app initially hidden?

Quote:
>I need to write a dialog app that starts out initially hidden. Is there any
>other way besides creating a normal hidden window and calling DoModal from
>there? Windows seems to ignore the fact that I don't have a WS_VISIBLE flag
>set.

Gil,

I don't know of any way other than to have a hidden owner/parent
window. Here's a solution I've posted a few times before:

BOOL CInvDlgApp::InitInstance()
{
        // Normal MFC generated code...

        // Doctored version of BekiM's stealth code

        // (m_wndOwner is a member CWnd I've added to
        // the application class)

        if ( m_wndOwner.m_hWnd == NULL )
        {
                LPCTSTR pstrOwnerClass = AfxRegisterWndClass(0);

                if ( !m_wndOwner.CreateEx(0, pstrOwnerClass, _T(""),
                                WS_POPUP, CW_USEDEFAULT,
                                CW_USEDEFAULT,
                                CW_USEDEFAULT,
                                CW_USEDEFAULT,
                                NULL, 0) )
                        return FALSE;
        }

        CInvDlgDlg dlg( &m_wndOwner );
        m_pMainWnd = &dlg;
        int nResponse = dlg.DoModal();
        if (nResponse == IDOK)
        {
                // TODO: Place code here to handle when the dialog is
                //  dismissed with OK
        }
        else if (nResponse == IDCANCEL)
        {
                // TODO: Place code here to handle when the dialog is
                //  dismissed with Cancel
        }

        // Destroy the invisible window
        if (m_wndOwner.m_hWnd != NULL)
                m_wndOwner.DestroyWindow();

        return FALSE;

Quote:
}

BOOL CInvDlgDlg::OnInitDialog()
{
        // Normal MFC generated template code....

        // TODO: Add extra initialization here

        /* Remove the WS_EX_APPWINDOW style */
        ModifyStyleEx( WS_EX_APPWINDOW, 0 );

        return TRUE;

Quote:
}

Dave
----
Address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow up email copies.


Tue, 26 Sep 2000 03:00:00 GMT  
 Can I start a dialog app initially hidden?

In the Resource Editor, enter to the dialog properties and turn off the
"Visible" option.


Quote:
>I need to write a dialog app that starts out initially hidden. Is there any
>other way besides creating a normal hidden window and calling DoModal from
>there? Windows seems to ignore the fact that I don't have a WS_VISIBLE flag
>set.

>Gil Rosin




Wed, 27 Sep 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

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

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

3. How to Start Dialog App Hidden?

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

5. Q:How do I start a Dialog App in a HIDE state

6. How to hide a dialog box initially?

7. HOWTO: Showing a dialog initially hidden???

8. Initially showing a dialog base application hidden - how?

9. Can I start my SDI app hidden?

10. Help: Starting MFC app with its window hidden

11. Starting app with hidden window

12. Q: Start App hidden

 

 
Powered by phpBB® Forum Software