Question

I want to display message on PC which may not be attended. The user can read the message when he comes back.

Execution of my app must continue, so I need something non-modal. Before I starting code & creating new forms, I would like ask if there is something like `ShowMessage' which is non-modal.


[Update] Thanks for the feedback so far. I do know how to do it using a form, I just wondered if there something that would involve me writing less code. It seems not. I shall search the VCL component sites to see if someone has already inverted this particular wheel.

It looks like the short answer to my question is "no".

Was it helpful?

Solution

From what I know - the answer is "no".

There's not much use of such non-modal message box because indeed, message box implies that program can not continue without getting users feedback (Yes/No/Ok/Cancel) or verifying user read it (Ok).

Without knowing other details, I guess you need a log, not a pile of unhandled message boxes. Worst case scenario, how many such messages do you expect to pile up if LAN breaks down, or something like that, 5, 20, 1000?

Create another form with a TMemo in it and when your program needs to report something - display the form and add the string to that Memo. So when the user returns back, he sees that log.

Making a custom TForm with a TMemo or TLabel on it and a public procedure AppendLog(aMsg: string); is a matter of 10min, much shorter than what you will spend on searches and definitely a better fit to your usage scenario.

OTHER TIPS

For only showing a notification message to user without interupting application workflow what you should use are Windows Balloon Tips. These are those Balloon shaped messages which pop-up above system tray. Easiest way of showing them with Delphi is to use TTrayIcon (available since Delphi XE if I'm not mistaken) http://docwiki.embarcadero.com/CodeExamples/XE5/en/TTrayIcon_(Delphi) http://docwiki.embarcadero.com/Libraries/XE5/en/Vcl.ExtCtrls.TTrayIcon

Default behavior of Balloon tips is that they stay visible when user is away from PC and only hide some time after user activity. So this almost guarante that user will see the message. You can set the time for this Balloon Tip to be visible. You can create a custom event which will be fired when user clicks on Balloon Tip (presenting some choice to the user for instance). Another advantage of Balloon Tips is that they don't popup when you are using any FullScreen aplications like games, movie players, etc. They will popu as soon as you leave the FullScreen mode of any of those applications.

Take a look at the function CreateMessageDialog in unit Vcl.Dialogs. This returns a the standard VCL MessageDialog form which you can manipulate, if necessary, and then show, modal or normally, as you wish.

You should look at JvDesktopAlert from the JVCL. It provides similar functionality to the TTrayIcon BallonHint, but is more configurable and can show multiple (stacked) windows. It is supported at least as far back as Delphi 7.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top