Solved

Disappearing messageDlgs

Posted on 2003-12-04
8
1,026 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
  • 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 125 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
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 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

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now