@Rucia, my suggestion is wich you use the OnException
Event from the TApplicationEvents
component, and then create your own dialog using the CreateMessageDialog
function.
see this sample.
procedure TForm1.ApplicationEvents1Exception(Sender: TObject; E: Exception);
var
MyDialogMsg : TForm;
ALeft : Integer;
ATop : Integer;
begin
//Create the dialog with the exeception message
MyDialogMsg := CreateMessageDialog(E.Message, mtError, [mbOk]);
try
//Calculate the pos of the dialog using the Screen.ActiveForm and the dialog size.
ALeft := Screen.ActiveForm.Left + (Screen.ActiveForm.Width div 2) - (MyDialogMsg.Width div 2);
ATop := Screen.ActiveForm.Top + (Screen.ActiveForm.Height div 2) - (MyDialogMsg.Height div 2);
if ALeft < 0 then ALeft := Screen.ActiveForm.Left;
if ATop < 0 then ATop := Screen.ActiveForm.Top;
if (ALeft + MyDialogMsg.Width > Screen.Width) or (ATop + MyDialogMsg.Height > Screen.Height)
then
begin
ALeft := (Screen.Width - MyDialogMsg.Width) div 2;
ATop := (Screen.Height - MyDialogMsg.Height) div 2;
MyDialogMsg.SetBounds (ALeft, ATop, MyDialogMsg.Width, MyDialogMsg.Height);
end
else
MyDialogMsg.SetBounds(ALeft, ATop, MyDialogMsg.Width, MyDialogMsg.Height);
//show the dialog
MyDialogMsg.ShowModal;
finally
MyDialogMsg.Free;
end;
end;