Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to Hide a dialog on App startup

Posted on 1998-12-21
8
378 Views
Last Modified: 2013-11-20
I have an application that's main window is a dialog box.  It has a taskbar icon associated with it.  How do I hide the window at the start of the application?  I tried to call ShowWindow() in the Create, OnCreate, and InitDialog with no luck.  Also, I tried to set the m_nCmdShow of the dialog in the App Class with no luck.
0
Comment
Question by:healer
8 Comments
 
LVL 12

Expert Comment

by:migel
ID: 1326552
Hi! You can use SetWindowPos function with SWP_HIDEWINDOW.
0
 
LVL 4

Expert Comment

by:nil_dib
ID: 1326553
Did you try ShowWindow(SW_HIDE) ?
0
 
LVL 2

Expert Comment

by:wyy_cq
ID: 1326554
in the yourDlg::OnInitDialog
{
 ...
 ShowWindow(SW_HIDE);
 return FALSE;
}
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:healer
ID: 1326555
I tried calling the ShowWindow(SW_HIDE) in the OnInitDialog and then returning FALSE,  The dialog still shows up.
0
 

Accepted Solution

by:
joshual earned 50 total points
ID: 1326556
You can only call ShowWindow(SW_HIDE) after the Dialog is created and not at OnInitDialog. I did it but setting a 10msec timer at OnInitDialog and call ShowWindow at OnTimer.

You might see the Dialog blink once. This can be overcome by moveing the dialog out of the screen.

0
 
LVL 12

Expert Comment

by:migel
ID: 1326557
You Can create modeless dialog (do not forget turn off WS_VISIBLE style)
0
 
LVL 2

Expert Comment

by:wyy_cq
ID: 1326558
set a timer in OnInitDialog...
{
  SetTimer(1,1,NULL);
  PostMessage(WM_SYSCOMMAND,SC_MINIMIZE ,0);//optional
..
}

defien timer handler
XXX::OnTimer(...)
{
  KillTimer(1);
  ShowWindow(SW_HIDE);
  ....
}
0
 

Expert Comment

by:dagangwang
ID: 1326559
1. Create a window without "WS_VISIBLE" style;
2. In this window, create your dialog. This window is dialog's parent window;
    Thus, initial window is not visible, dialog is not visible also.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question