?
Solved

Hidden window creation

Posted on 1999-01-10
9
Medium Priority
?
296 Views
Last Modified: 2013-11-20
 Hey guys. I'm developing a Dialog based application. I need that the main window (a CDialog derived) stays initially hidden. How can i do it? I've been tried checking off the option "Visible" in the resource editor and it doesn't work. I've been tried calling ShowWindow(SW_HIDE) in OnInitDialog() function and it doesn't work. I've tried ModifyStyle(WS_VISIBLE, 0) in OnInitDialog() and it doesn't work. I've tried this:

      lpCreateStruct->style&= ~WS_VISIBLE;
      if (CDialog::OnCreate(lpCreateStruct) == -1)
            ....

in OnCreate(...) function and it doesn't work.

Thanks in advance,

Jose.
0
Comment
Question by:fjsen
9 Comments
 

Expert Comment

by:Eyalt
ID: 1327444
Is it an OCX? Why do you need to hide the appliction which U have just execute?
Anyway maybe the HideApplication() function will help U .

0
 

Expert Comment

by:Eyalt
ID: 1327445
Is it an OCX? Why do you need to hide the appliction which U have just execute?
Anyway maybe the HideApplication() function will help U .

0
 

Expert Comment

by:Eyalt
ID: 1327446
Or use the API method : WinMain (...)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:thresher_shark
ID: 1327447
If it is an OCX, it probably wouldn't be dialog based...

Try this (put in the InitDialog function):
SetWindowPos (NULL, 0, 0, 0, 0, SWP_HIDEWINDOW);

if that doesn't work, try this:
SendMessage (WM_SHOWWINDOW, FALSE, 0);

Let me know how that works...
0
 

Expert Comment

by:Christ142
ID: 1327448
Edit your C...App::INitInstance()
Replace
CYourDlg dlg;
if( dlg.DoModal() )
...
return FALSE;

to be

CYourDlg * pDlg = new CYourDlg;
pDlg->Create( CYourDlg::IDD );
m_pMainWnd = pDlg;
pDlg->ShowWindow( SW_HIDE );
return TRUE;

and you won't see your dialog anymore. I garuntee.

0
 

Author Comment

by:fjsen
ID: 1327449
This solution is not valid for me because:
- I need to hide the main dialog but i create a notify icon. The user can show the dialog double clicking in this notify icon.
- Once the user has showed the main dialog, the application doesn't end clicking the X button.

Thanks.
0
 
LVL 1

Expert Comment

by:majorjohn
ID: 1327450
Hi!
Here is your answer :
Replace  your Application Class's InitInstance  code

CCurrentDlg dlg;
if( dlg.DoModal() )
.
return FALSE

With

CCurrentDlg * pDlg = new CCurrentDlg;
pDlg->Create( CCurrentDlg::IDD );
m_pMainWnd = &pDlg;
pDlg->ShowWindow( SW_HIDE );
return TRUE;

I think it will work. Let me know if you want more explanation.

0
 

Author Comment

by:fjsen
ID: 1327451
I need my dialog to be modal
0
 
LVL 1

Accepted Solution

by:
bitq earned 100 total points
ID: 1327452
majorjohn was right:
If your main wnd is a dialog it mast be a modaless

Here is code:
CCurrentDlg dlg;
m_pMainWnd = &dlg;
if( dlg.DoModal() )
      return FALSE

you can track into the DoModal func
and you'll find the DoModal just create a modaless
dialog.

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

839 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