Solved

Hidden window creation

Posted on 1999-01-10
9
291 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
[X]
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
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
Independent Software Vendors: 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 50 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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

732 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