Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Disappearing messageDlgs

Posted on 2003-12-04
8
Medium Priority
?
1,054 Views
Last Modified: 2012-08-13
Hi all,

I've got the following problem :
I've created an application, which uses a pagecontrol to show different parts of functionality of the program. For the setup part of the program, I've chosen to add a form, which "hovers" above the mainform. Because the setupform would disappear if I clicked on the mainform, I've made the setupform.FormStyle fsStayOnTop.

All was well, until I got the bright idea to notify the user if a change had been made...To do the notification, I make use of a MessageDlg. If the user clicks on the button, all is well of course. But when the user clicks somewhere else, the messagedlg disappears, and can only be found by minimizing the application!

I've found one solution myself, but that didn't really help : Using NormalizeTopMost and RestoreTopMost. This does indeed make the setupforms formstyle fsNormal, and the MessageDlg always appears. But now both disappear when I click on the mainform.

The strange thing is, the MessageDlg's I call from the mainform do not have this problem!

Any help would be appreciated!

Binsky
0
Comment
Question by:Binsky
[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
  • 3
  • 3
  • 2
8 Comments
 

Expert Comment

by:hatchy
ID: 9874237
The best thing you can do is not use setupform.FormStyle fsStayOnTop.Instead do

setupform.ShowModal;

when you show the form .. that way the form will stay on top of the others and you wont be allowed to 'play' with the other forms while its open

Now twhen you do a messagedlg the form shouldnt 'overlap' the dialogue but should stay on top of it

good luck :)

--HaTcHeT
0
 
LVL 1

Author Comment

by:Binsky
ID: 9875015
Alright,

I'll checkit out, it seems like a very very good tip to me! I was getting pretty annoyed with the stayontop business...My last project had a lot of checking for stayontop and visibility, I was planning on not having to repeat that in this project...

But it will be a while until I check it, I'm going home from work now, and won't be back till tuesday! (So it'll take a few days for the points, if this works for me, which I'm sure it will..)

Thanks a lot,

Binsky
0
 
LVL 17

Accepted Solution

by:
geobul earned 500 total points
ID: 9875162
Hi,

Try windows.MessageBox function instead:

procedure TForm2.Button1Click(Sender: TObject);
begin
  if windows.MessageBox(Handle, PChar('the text'), PChar('the caption'), MB_OKCANCEL or MB_ICONQUESTION or MB_APPLMODAL or MB_TOPMOST) = IDOK then begin
    // do something
  end;
end;

Regards, Geo
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:Binsky
ID: 9902547
Okay,

I've tried the showmodal, but that is a bit too agressive for my taste...The form doesn't need to "take control" of the application, so that is not a good solution to my problem(sorry)

The messagebox solution also didn't work at first, but after some tweaking I got it to work.

I've solved it so far, using a bit of my own, and a bit of Geo's solution... :

      with Application do
      begin
         NormalizeTopMosts;
         MessageBox('This should be on top.', 'Look', mrOK);
         RestoreTopMosts;
      end;

Geo (or anyone), how do I create a MessageBox which contains only an Ok button? Using the MBOk constant doesn't appear to work for me...Do I need to include something special in my "uses" part of the unit? (I couldn't find which unit I should include in the helpfile).

Binsky


0
 
LVL 17

Expert Comment

by:geobul
ID: 9908371
Hi,

uses Windows; // I hope you already have this in your unit

MessageBox('This should be on top.', 'Look', MB_OK);

Regards, Geo
0
 

Expert Comment

by:hatchy
ID: 9908412
or use

messagedlg( 'hello world', mtinformation, [mbok], 0);

--HaTcHeT
0
 
LVL 1

Author Comment

by:Binsky
ID: 9910579
Hello again,

Thanks Geo, that worked perfectly! Once I included Windows in my uses clause, all worked fine (I didn't have that yet...)

Sorry Hatchy, I know your last post is right, that it does deliver a messagebox with only an Ok button, but the messagedlg function was not the right "component" to solve this problem. But thanks for your time!

So the points are for Geo...

Binsky
0
 
LVL 17

Expert Comment

by:geobul
ID: 9910785
Thanks :-)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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 The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
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

670 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