Minimizing a dialog-based application on startup...? 
Author Message
 Minimizing a dialog-based application on startup...?

I've developed a MFC application that is dialog based (so it's not SDI or
MDI!): It's main window is a dialog. Because I've attached a tray icon to
this application and a Hide button it has the feature of hiding itself and
when double clicking on the tray icon it displays the window. When clicking
on the Hide button I just call ShowWindow(SW_HIDE). However I also want this
application to hide itself when started up. So I guessed I put the same call
into the OnInitDialog function, however that does not work.
Does anybody have a good idea to make this work. I tried SendMessage,
PostMessage (all from the OnInitDialog function), but they either don't work
or make the application end-up in an endless loop killing itself.

Regards,
Rob



Wed, 14 Jun 2000 03:00:00 GMT  
 Minimizing a dialog-based application on startup...?

Quote:
>When clicking
>on the Hide button I just call ShowWindow(SW_HIDE). However I also want this
>application to hide itself when started up. So I guessed I put the same call
>into the OnInitDialog function, however that does not work.

Rob,

I've not come across a really elegant way of doing this. The best I've
got is to 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. 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
----
Address is altered to discourage junk mail.
Remove ".---" for the real address.


Fri, 16 Jun 2000 03:00:00 GMT  
 Minimizing a dialog-based application on startup...?

Quote:

>When clicking
>on the Hide button I just call ShowWindow(SW_HIDE). However I also want
this
>application to hide itself when started up. So I guessed I put the same
call
>into the OnInitDialog function, however that does not work.

Try this in OnInitDialog:
    SetWindowPos(&wndBottom, 0,0,0,0, SWP_HIDEWINDOW | SWP_NOACTIVATE);


Sun, 18 Jun 2000 03:00:00 GMT  
 Minimizing a dialog-based application on startup...?

Quote:
>Try this in OnInitDialog:
>    SetWindowPos(&wndBottom, 0,0,0,0, SWP_HIDEWINDOW | SWP_NOACTIVATE);

Michael,

That doesn't hide it - it makes it non-existent (size-wise). The
window still appears in the taskbar & Alt+Tab window.

Dave
----
Address is altered to discourage junk mail.
Remove ".---" for the real address.



Sun, 18 Jun 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

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

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

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

4. Start a dialog based application minimized

5. minimize dialog base application

6. Minimizing Dialog Window on Startup

7. Hide dialog based app on startup

8. Question on Dialog based app startup

9. Hiding a dialog based app on startup

10. Adding a minimize button to an existing dialog based app

11. Starting a Dialog Based app minimized.

12. Minimize parent from a CDialog-based dialog?

 

 
Powered by phpBB® Forum Software