Solved

Hidden window creation

Posted on 1999-01-10
9
287 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
Comment Utility
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
Comment Utility
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
Comment Utility
Or use the API method : WinMain (...)
0
 
LVL 6

Expert Comment

by:thresher_shark
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Expert Comment

by:Christ142
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I need my dialog to be modal
0
 
LVL 1

Accepted Solution

by:
bitq earned 50 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now