[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Modal Dialog on Top

Posted on 1997-02-20
13
Medium Priority
?
731 Views
Last Modified: 2013-11-20
I would like to create a modal dialog, and place it as the topmost window. However, the form view which created this dialog must stay in the same Z-order position (ie if it is hidden by another window it must remain hidden).

I have tried to call SetWindowPos in the OnInitDialog handler of the modal dialog, with the 'Modal dialog' flag set. However, I find that although the modal dialog does appear (the title bar shows as inactive), whenever you click on it the formview appears behind it. I have used  &wndTop for the first parameter to SetWindowPos(). Is there anything else I need to do?

0
Comment
Question by:rjohnston
  • 6
  • 6
13 Comments
 
LVL 4

Expert Comment

by:mbhakta
ID: 1300333
Your question sounds like a patent MFC problem. Modal Dialog boxes in MFC don't work the way they work in a generic C manner. DoModal() call actually resets window styles for that dialog and overwrites it with its own stuff.

Now if you are working on 95 or NT 4.0 and Vc++ 4.x you should be able to do the following.

After you create your resource in VC++. Set the two check boxes  'System Modal' and 'Set foreground' styles. This will bring your dialog box to the top most position to all other windows.
0
 

Author Comment

by:rjohnston
ID: 1300334
I have tried this solution in the past, and I get the same problem. The modal dialog box does indeed come to the foreground, but it also 'pulls' the form view that created it into the foreground as well (actually, just behind the modal dialog box). I need the form view to stay where it is, and not be displayed.
0
 
LVL 4

Expert Comment

by:mbhakta
ID: 1300335
I think you are doing something wrong somewhere. I have this code ready for you which is a formview based SDI app. If I click on the formview, I get a CDialog based modal dialog based application which remains on top without bringing the view on top no matter where you are. Get me your e-mail address and I will mail you the solution.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:rjohnston
ID: 1300336
I do not click on the formview, its an external event (a message sent by TAPI) which causes the form view to create the dialog box.
(johnston_r@telsci.co.uk)
0
 
LVL 4

Expert Comment

by:mbhakta
ID: 1300337
Shouldn't really matter, as long as it is a modal Dialog box. Anyway, i am mailing you the code as it is. Might be of help to you.
0
 
LVL 4

Expert Comment

by:mbhakta
ID: 1300338
Something wrong with you e-mail address. I am getting an error if I send you the code. Please check...
0
 

Author Comment

by:rjohnston
ID: 1300339
Sorry, rjohnston@telsci.co.uk
0
 
LVL 4

Expert Comment

by:mbhakta
ID: 1300340
Sorry, mate I tried mailing you the reply to your second query. I got problems with the above e-mail address. If you haven't received any mail please reply back with a stable e-mail address.

Thanks
0
 
LVL 4

Expert Comment

by:mbhakta
ID: 1300341
I think there looks to be some real problem with your IProvider. I have been trying to mail you a reply for your OnCancel query. But no luck.

Anyway here is a copy of the same :


Yes, this is possible. This is where the pParent of the constructor comes into picture. Also you can approach the problem another way. You have the call AfxGetMainWnd(). You can use this handle to call the following in your OnOK()/OnCancel();

           
AfxGetMainWnd()->ShowWindow();
if that is a problem
AfxGetMainWnd()->SetWindowPos( &CWnd::wndTop, ....);
should work.

0
 

Author Comment

by:rjohnston
ID: 1300342
I actually received your reply. I've been trying to answer it but I've had no luck!

Basically, I don't want to do anything in my OnCancel(). I want the parent to stay where it is (somewhere in the background). However, in my app, and in your test app, the parent automatically moves up the Z-order to the foreground. It is this behaviour I want to get rid of.
0
 

Author Comment

by:rjohnston
ID: 1300343
I haven't received any reply. Are you still having problems with your ISP? I will repost this question to everyone at the end of the week if I don't hear from you as I really need a solution.

0
 

Author Comment

by:rjohnston
ID: 1300344
mbhakta hasn't got in touch with me concerning my last point.
0
 
LVL 2

Accepted Solution

by:
sapek earned 600 total points
ID: 1300345
I'm not sure if understand everythink from your discusion (especially that some of it went through e-mail as I understand).
I understand that you can set your dialog to be top most window and all you need is to stop window that created the dialog to popup then the dialog is activated. I think that you will achive this when you create your dialog with owner window set to NULL. Because MFC normally won't allow you to do this you must overwrite DoModal (luckily it is virtual), copy original MFC's code, and in the call to CreateDlgIndirect (yes! modal dialogs are modless in MFC) replace the parameter CWnd::FromHandle(hWndParent) with NULL.

Adam
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

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 …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

872 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