Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Message box appears behind form !??

Posted on 2002-07-30
13
Medium Priority
?
1,126 Views
Last Modified: 2007-12-19
Hi Experts,

In my application a range of invoices can be printed. After the invoices are printed a message box (MessageDlg) pops up which indicates that the printing is ready.

Strange thing that sometimes happens on some pc's is that the message box won't be displayed on top of the form, but seems to be BEHIND the form.
I can see the printing is ready and that the program must have launched the message box; code before the message box is executed, code after the message box is not. The form of my program (an MDI-Child) however has focus instead of the message box. The form cannot be closed or moved; the whole program can't even be closed. The user can only quit the program using the Windows NT task manager.

I tried to change the MessageDlg message box to a ShowMessage message box, but the problem persists. The problem is difficult to trace because it doesn't occur always.

Can anyone tell me what could cause this behaviour? And is there a way to solve this?

Thanks,
JDN
0
Comment
Question by:JDN
  • 4
  • 2
  • 2
  • +4
13 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7187605
please show, how you show it
0
 
LVL 1

Author Comment

by:JDN
ID: 7187636
What? The message box?
I use this code:

MessageDlg('Invoices are printed.',mtInformation,[mbOK],0);

I changed the code to:

ShowMessage('Invoices are printed.');

But on some pc's the message box is sometimes not visible when launched. As I said, you can only quit the program with the Windows task manager.

JDN


0
 
LVL 17

Assisted Solution

by:geobul
geobul earned 75 total points
ID: 7187915
Hi,

Try:
 
Windows.MessageBox(0,'Invoices are printed.', PChar(Application.Title), MB_OK or MB_ICONINFORMATION or MB_TASKMODAL);

Perhaps something is wrong with the window handles.

Regards, Geo
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 6

Accepted Solution

by:
swift99 earned 75 total points
ID: 7189057
I have seen the same thing with some shrink wrapped packages (non-Delphi) on Windows NT 4 Service packs 3 and 6.  The problem is not endemic to Delphi, it appears to be a bug in Windows handling of modal dialogs.

I have found that I can normally use alt+tab to eventually bring the modal dialog to the foreground.
0
 
LVL 1

Author Comment

by:JDN
ID: 7189806
Swift99,

You may be right, because on the pc's with that problem the Microsoft Outlook message "You have new mail" also appears behind other screens. Normally this message box should appear on top of another screen.

I will try the Alt-Tab solution as soon as the problem occurs.

There's no other solution or bug-fix for this problem?
0
 
LVL 4

Expert Comment

by:jsweby
ID: 7190200
I think geobul's suggestion is the right one, it's the one I use. The Windows MessageBox allows you to define the handle which will be the owner of the message box; I usually set this to either the current form's handle (Self.Handle) or the application's main form (Application.MainForm.Handle).

J.
0
 
LVL 4

Expert Comment

by:jsweby
ID: 7190201
Oh yeah, and use the MB_TASKMODAL flag.

J.
0
 
LVL 17

Expert Comment

by:geobul
ID: 7190277
Thanks, jsweby. You are right about the handles. I've left the handle zero because I suppose that it's the problem actually. Both MessageDlg and ShowMessage functions create a new form using Application as the owner and show that form in modal state.

JDN, you may also add 'or MB_SETFOREGROUND' to the flags, which should internally call SetForegroundWindow API for this message box.

Regards, Geo
0
 

Expert Comment

by:CleanupPing
ID: 9342971
JDN:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 17

Expert Comment

by:geobul
ID: 9361522
I do care :-)
There was no complaint of my proposal, so I presume it solved the problem.
0
 
LVL 5

Expert Comment

by:snehanshu
ID: 9966114
Hi!
No comment has been added lately and this question is therefore classified abandoned.

If asker wishes to close the question, then refer to
http://www.experts-exchange.com/help/closing.jsp

Otherwise, I will leave a recommendation in the Cleanup topic area that this question is:

Split between geobul and swift99

Please leave any comments here within the next seven days. It is assumed that any participant not responding to this request is no longer interested in its final disposition.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

...Snehanshu
EE Cleanup Volunteer
0
 
LVL 6

Expert Comment

by:swift99
ID: 9966461
I say give the points to geobul.  I only had an observation, not a solution.
0
 
LVL 17

Expert Comment

by:geobul
ID: 9970531
swift99, I'm not sure whether JDN has tried my way at all :-)

My proposal: Split the points
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

963 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