Starting a Dialog Based app minimized. 
Author Message
 Starting a Dialog Based app minimized.

How to I start a dialog based program minimized so that it just shows up in
the system tray.  I've got all of the tray stuff working just fine.  If I
add my "MinimiseToTray" function in my InitDialog routine, you see dialog
being minimized when it is run which is not what I want.  I have also tried
to add the WS_MINIMIZE to my resource file, but my dialog still apprears.
What is the best way to do this?

Thanks,
Don Sanders



Sat, 06 Sep 2003 07:32:33 GMT  
 Starting a Dialog Based app minimized.
    The problem here is that a dialog isn't quite a window, and therefore
can't be altered through PreCreateWindow. No, that would be too easy. So
what you can do instead is handle this sort of style change in OnInitDialog.
    The key here is to do it BEFORE calling the parent class' method.
Example:

BOOL CMinimizeDlg::OnInitDialog()
{
    WINDOWPLACEMENT wp;
    // Get the current placement to preserve size, etc.
    GetWindowPlacement(&wp);
    // Set how you'd like it to be shown.
    wp.showCmd = SW_MINIMIZE;
    SetWindowPlacement(&wp);

    // Carry on as usual.
    CDialog::OnInitDialog();

    SetIcon(m_hIcon, TRUE);   // Set big icon
    SetIcon(m_hIcon, FALSE);  // Set small icon

    // TODO: Add extra initialization here

    return TRUE;  // return TRUE  unless you set the focus to a control

Quote:
}

Hope that helps.


Sat, 06 Sep 2003 08:14:45 GMT  
 Starting a Dialog Based app minimized.
Hi Don...
                An alternative to using WINDOWPLACEMENT  &
GetWindowPlacement() is

                ShowWindow ( SW_MINIMIZE );

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


Quote:
>     The problem here is that a dialog isn't quite a window, and therefore
> can't be altered through PreCreateWindow. No, that would be too easy. So
> what you can do instead is handle this sort of style change in
OnInitDialog.
>     The key here is to do it BEFORE calling the parent class' method.
> Example:

> BOOL CMinimizeDlg::OnInitDialog()
> {
>     WINDOWPLACEMENT wp;
>     // Get the current placement to preserve size, etc.
>     GetWindowPlacement(&wp);
>     // Set how you'd like it to be shown.
>     wp.showCmd = SW_MINIMIZE;
>     SetWindowPlacement(&wp);

>     // Carry on as usual.
>     CDialog::OnInitDialog();

>     SetIcon(m_hIcon, TRUE);   // Set big icon
>     SetIcon(m_hIcon, FALSE);  // Set small icon

>     // TODO: Add extra initialization here

>     return TRUE;  // return TRUE  unless you set the focus to a control
> }

> Hope that helps.



Sat, 06 Sep 2003 23:09:12 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Dialog-based app starting minimized

2. Start a dialog based application minimized

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

4. start dialog app minimized

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

6. Dialog-based app, always minimized

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

8. Detect when dialog-based app is minimized?

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

10. Q: Smart Minimize and MFC Dialog Based App

11. Help please - Dialog-based app won't start - Acc Vio C0000005 - VC 5 - Win200

12. dialog based mfc app that starts without showing the main window

 

 
Powered by phpBB® Forum Software