Solved

Hidden window creation

Posted on 1999-01-10
9
289 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Generic progress indicator 6 116
maxBlock challenge 30 128
Unix Command -- Challenging  question 7 88
Problem to App source 6 37
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: 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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

776 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