Hide dialog based apps 
Author Message
 Hide dialog based apps

Does anybody know why 'ShowWindow(SW_HIDE)' does not work in
'OnInitDialog()' function of an dialog based app. The problem is that I have
an dialog based app with only one window (the main dialog) and I can't hide
it with ShowWindow()
Does anyone knows why?

Thanx
Sorin



Fri, 25 Oct 2002 03:00:00 GMT  
 Hide dialog based apps
Because the dialog code forces the dialog visible after you return.
You can hide it after OnInitDialog; post a user-defined message and
handle it there. Not elegant, since you get a flash of the window when
the app comes up, but otherwise it suffices.
                        joe



Quote:
>Does anybody know why 'ShowWindow(SW_HIDE)' does not work in
>'OnInitDialog()' function of an dialog based app. The problem is that I have
>an dialog based app with only one window (the main dialog) and I can't hide
>it with ShowWindow()
>Does anyone knows why?

>Thanx
>Sorin

Joseph M. Newcomer [MVP]

Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm


Fri, 25 Oct 2002 03:00:00 GMT  
 Hide dialog based apps
Cause your dialog in shown in the idle loop, after oninitdialog... if you
look in DoModal(...) you'll see:

[lot of code]
    DWORD dwFlags = MLF_SHOWONIDLE;
    if (GetStyle() & DS_NOIDLEMSG)
     dwFlags |= MLF_NOIDLEMSG;
    VERIFY(RunModalLoop(dwFlags) == m_nModalResult);
[lot of code]

So you ask your window to hide before it's shown... how to get rid of this?

I guess it's not the perfect way, but simply make a new function in your
dialog (for instance DoModalNotVisible() ) in this function, you'll copy
paste the MFC DoModal code and remove the
    DWORD dwFlags = MLF_SHOWONIDLE; line...

It works for me... hope also for you...

Tenebrax



Fri, 25 Oct 2002 03:00:00 GMT  
 Hide dialog based apps

Quote:

>Does anybody know why 'ShowWindow(SW_HIDE)' does not work in
>'OnInitDialog()' function of an dialog based app. The problem is that I have
>an dialog based app with only one window (the main dialog) and I can't hide
>it with ShowWindow()

If you want a clean implementation of a hidden dialog-based
application, the best way is to make the dialog modeless. It's easy to
do, and there's sample code for doing this on my web site. See the URL
below, and go to tip 26 on the Win32 Code page.

--
Bob Moore [MVP]
http://www.mooremvp.freeserve.co.uk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Due to an unreasonable amount of queries, I no
longer answer unsolicited email questions. Sorry,
no exceptions.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Sat, 26 Oct 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Hide dialog based app on startup

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

3. hiding an mfc dialog based app

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

5. Hiding a dialog-based app

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

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

8. Hiding a dialog based app on startup

9. Resizing a dialog based app based on its view's size

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

11. Modeless dialog in a dialog-based app

12. dialog within dialog based apps

 

 
Powered by phpBB® Forum Software