ShowMessage, control position? (SOLVED) lazarus / 31-LCL ---------------------------------------------------------------------- mijen67 · 2018-01-03 14:00 Is it possible to control position of a ShowMessage dialog? It would be great if it was possible to capture mouse cursor position and let dialog pop up near mouse cursor. Maybe capture mouse position last time it clicked something in a form? ---------------------------------------------------------------------- balazsszekely · 2018-01-03 14:51 Create a new form, add OnMouseUp event, then: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function MessageDlgEx(const AMsg: string; AX, AY: Integer; ADlgType: TMsgDlgType;  AButtons: TMsgDlgButtons): TModalResult;var  MsgFrm: TForm;begin  MsgFrm := CreateMessageDialog(AMsg, ADlgType, AButtons);  try        MsgFrm.FormStyle := fsSystemStayOnTop;    MsgFrm.Position := poDefaultSizeOnly;    MsgFrm.Left := AX;    MsgFrm.Top := AY;    Result := MsgFrm.ShowModal;  finally    MsgFrm.Free  end;end; procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;  Shift: TShiftState; X, Y: Integer);var  P: TPoint;begin  P.X := X;  P.Y := Y;  P := Form1.ClientToScreen(P);  MessageDlgEx('This is a test!', P.X, P.Y, mtInformation, [mbOk]);end; ---------------------------------------------------------------------- guest61674 · 2018-01-03 16:18 How to implement in this function the option of time to cancel if not pressed a button? tks ---------------------------------------------------------------------- balazsszekely · 2018-01-03 16:51 QuoteHow to implement in this function the option of time to cancel if not pressed a button?In that case you should implement your own custom form with a timer for example. The attached example also works. ---------------------------------------------------------------------- howardpc · 2018-01-03 18:37 Note that the Dialogs unit also includes this procedure Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure ShowMessagePos(const aMsg: string; X, Y: Integer); ---------------------------------------------------------------------- jamie · 2018-01-03 22:40 Isn't it "MessageDlgPos(.... ? ---------------------------------------------------------------------- howardpc · 2018-01-03 22:51 Yes, there's MessageDlgPos() as well. But that is not a simple Pos analogue of ShowMessage(). ShowMessagePos just takes  X and Y parameters in addition to the displayed text parameter. MessageDlgPos() is more complex, and requires you to choose an icon and specify which (and how many) buttons to show. It also takes a HelpContext parameter. ---------------------------------------------------------------------- mijen67 · 2018-01-06 22:23 Quote from: GetMem on January 03, 2018, 03:51:44 pmCreate a new form, add OnMouseUp event, then: Thanks! Works great! To use it for click on button I used: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);var  P: TPoint; begin  P := Mouse.CursorPos;   // P := Form1.ClientToScreen(P);  MessageDlgEx('This is a test!', P.X, P.Y, mtInformation, [mbOk]);end; ---------------------------------------------------------------------- mijen67 · 2018-01-06 22:45 Quote from: howardpc on January 03, 2018, 07:37:37 pmNote that the Dialogs unit also includes this procedure Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure ShowMessagePos(const aMsg: string; X, Y: Integer); Nice that the "standard" units can handle position as well (to keep things simple). I changed a dialog from: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if MessageDlg('Question', 'Do you wish to show Selectable?',   mtConfirmation, [mbYes, MbNo], 0) = mrYes then to: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  pt: TPoint; ... if MessageDlgPos('Do you wish to show Selectable?',   mtConfirmation, [mbYes, MbNo], 0, pt.X, pt.Y) = mrYes then But clearly the options for replacing MessageDlg with MessageDlgPos are not 1:1 see http://lazarus-ccr.sourceforge.net/docs/lcl/dialogs/messagedlg.html and http://lazarus- ccr.sourceforge.net/docs/lcl/dialogs/messagedlgpos.html