Solved

Disappearing messageDlgs

Posted on 2003-12-04
8
1,024 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 1

Author Comment

by:Binsky
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 17

Expert Comment

by:geobul
Comment Utility
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
Comment Utility
or use

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

--HaTcHeT
0
 
LVL 1

Author Comment

by:Binsky
Comment Utility
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
Comment Utility
Thanks :-)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
PDF files into SQL 2008 Varbinary(Max) 3 73
IExtractImage Delphi 14 162
delphi exception 7 58
Help on project with Soap 10 42
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…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

11 Experts available now in Live!

Get 1:1 Help Now