?
Solved

Hidden window creation

Posted on 1999-01-10
9
Medium Priority
?
293 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
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

765 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