Again: minimizing dialog-based app on startup.... 
Author Message
 Again: minimizing dialog-based app on startup....

Hi there,

Maybe I'm a little impatient, but for those who didn't see my earlier
posting and have a solution, please reply...

- Start earlier message

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

- End earlier message



Sun, 18 Jun 2000 03:00:00 GMT  
 Again: minimizing dialog-based app on startup....

You can make the dialog modeless. Check out Kb article "Creating a
Modeless Dialog Box with MFC Libraries" ID: Q103788. Then you can use
ShowWindow (SW_HIDE)  or create it invisible and show it only when
needed.


Quote:

> Hi there,

> Maybe I'm a little impatient, but for those who didn't see my earlier
> posting and have a solution, please reply...

> - Start earlier message

> 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

> - End earlier message

--
Girish Bharadwaj
Software developer
http://members.tripod.com/~GBharadwaj/index.html




Sun, 18 Jun 2000 03:00:00 GMT  
 Again: minimizing dialog-based app on startup....


Quote:
>Hi there,

>Maybe I'm a little impatient, but for those who didn't see my earlier
>posting and have a solution, please reply...

>- Start earlier message

>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

>- End earlier message

I'm new here. Hope I don't steer you wrong.
Could you try WS_VISIBLE in PreCreateWindow? First look in the source code
for PreCreateWindow and override it. Change the style in the CREATESTRUCT by
anding it with the negation of WS_VISIBLE. For those not using MFC, just
don't add WS_VISIBLE to the style when calling CreateWindow.

Ya might want to read the help for PreCreateWindow first, too. <grin>
--
David L Smith



Sun, 18 Jun 2000 03:00:00 GMT  
 Again: minimizing dialog-based app on startup....

Hi!

The problem is that application is dialog-based and this dialog will be
always visible at startup.

Quote:

>I'm new here. Hope I don't steer you wrong.
>Could you try WS_VISIBLE in PreCreateWindow? First look in the source code
>for PreCreateWindow and override it. Change the style in the CREATESTRUCT
by
>anding it with the negation of WS_VISIBLE. For those not using MFC, just
>don't add WS_VISIBLE to the style when calling CreateWindow.

--
----------------------------------------
Valery Rastorguev

----------------------------------------


Mon, 19 Jun 2000 03:00:00 GMT  
 Again: minimizing dialog-based app on startup....

Quote:

> >Hi there,

> >Maybe I'm a little impatient, but for those who didn't see my earlier
> >posting and have a solution, please reply...

> >- Start earlier message

> >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

> >- End earlier message

I faced the same problem a few months ago, and here's the solution I
found.
The code below can be added to a dialog-based app as generated by App
Wizard
(or any other dialog-based app for that matter) to give it the behavior
you're looking for.  The code should go into the CDialog-derived class
for your main
window.

- Add a visible flag.  In the dialog's constructor initialize it to
FALSE
(i.e. hidden).

    BOOL    m_bVisible;

- Add a handler for OnWindowPosChanging.  You'll have to add it by hand
as
it's not directly supported by ClassWizard (at least not in VC 4.1, I
don't
know about 5.0).

    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 );
        }
    }

- Add calls to the display function.

    DisplayWindow( TRUE )    // in response to a context-menu selection

    DisplayWindow( FALSE )   // when the user closes the dialog

HTH,
Eliot Rogers



Fri, 23 Jun 2000 03:00:00 GMT  
 Again: minimizing dialog-based app on startup....

Quote:

>m_bVisible

You could eliminate this flag by caling IsWindowVisible () where
necessary.

Bob Moore [MVP]

-----------------------------------------------
Due to an unreasonable amount of queries, I no
longer answer emailed questions. Sorry.
-----------------------------------------------



Sat, 24 Jun 2000 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

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

2. Minimizing a dialog-based application on startup...?

3. Hide dialog based app on startup

4. Question on Dialog based app startup

5. Hiding a dialog based app on startup

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

7. Starting a Dialog Based app minimized.

8. Dialog-based app starting minimized

9. Dialog-based app, always minimized

10. Detect when dialog-based app is minimized?

11. Q: Smart Minimize and MFC Dialog Based App

12. Menus and dialog-based apps (again)

 

 
Powered by phpBB® Forum Software