Link to home
Start Free TrialLog in
Avatar of Binsky
Binsky

asked on

Disappearing messageDlgs

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
Avatar of hatchy
hatchy

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
Avatar of Binsky

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of geobul
geobul

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Binsky

ASKER

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


Hi,

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

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

Regards, Geo
or use

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

--HaTcHeT
Avatar of Binsky

ASKER

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
Thanks :-)