Nico Preto 0 Posted March 25, 2021 I'm using Application.MessageBox in my project. When used in multiple monitors, when called then message appears every time in the primary monitor. But I need the message centered in the current visible form. Any idea? Share this post Link to post
Lajos Juhász 293 Posted March 25, 2021 I've tested using XE5 and 10.4.2 in both versions the message appears on the correct monitor. Share this post Link to post
KodeZwerg 54 Posted March 25, 2021 to full customize positioning you could use MessageDlgPos() or ShowMessagePos() methods aswell. Share this post Link to post
KodeZwerg 54 Posted March 25, 2021 var MyMsg: TForm; begin MyMsg := CreateMessageDialog('put Message in here...', mtCustom, [mbOK]); MyMsg.Position := poOwnerFormCenter; MyMsg.ShowModal; end; Easiest solution this might be? Share this post Link to post
dummzeuch 1505 Posted March 25, 2021 1 hour ago, Nico Preto said: I'm using Application.MessageBox in my project. When used in multiple monitors, when called then message appears every time in the primary monitor. But I need the message centered in the current visible form. That's one of my major gripes with Windows. The only solution I know is to roll your own or use an existing library. So I wrote my own. You can find it here; https://osdn.net/projects/dzlib-tools/svn/view/dzlib/trunk/forms/?root=dzlib-tools in Unit w_dzDialog. Share this post Link to post
KodeZwerg 54 Posted March 26, 2021 10 hours ago, Nico Preto said: Thanks guys Could you at least tell what solution was working well for you to enlighten others by reading your topic? Share this post Link to post
Guest Posted March 26, 2021 (edited) hi @Nico Preto you can try my sample: MessageDLGPOS() will go use "TTaskMessageDialog" and you can use it directly include saying the "POSITION" on the screen. say... it will use "TCustomTaskDialog" procedure TForm1.Button1Click(Sender: TObject); var lMyMonitor: TMonitor; // X1 : integer; Y1 : integer; lOffSetWindowWidth : integer; lOffSetWindowHeight: integer; begin lMyMonitor := Screen.MonitorFromWindow(Self.Handle); // lOffSetWindowWidth := 100; // needs calculate it before show the window, of course... lOffSetWindowHeight := 50; // X1 := Random(lMyMonitor.Width - lOffSetWindowWidth); Y1 := Random(lMyMonitor.Height - lOffSetWindowHeight);; // try Memo1.Lines.Add(Format('Monitor = %d', [lMyMonitor.MonitorNum])); Memo1.Lines.Add(Format('Monitor Height=%d, Width=%d', [lMyMonitor.Height, lMyMonitor.Width])); Memo1.Lines.Add(Format('Monitor Left=%d, Top=%d, Height=%d, Width=%d', [ { } lMyMonitor.WorkareaRect.Left, { } lMyMonitor.WorkareaRect.Top, { } lMyMonitor.WorkareaRect.Height, { } lMyMonitor.WorkareaRect.Width { } ])); // Memo1.Lines.Add(Format('X1=%d, Y1=%d', [X1, Y1])); // Vcl.Dialogs.MessageDlgPos('msg string', mtInformation, [mbOK], 0, X1, Y1); finally // end; end; hug Edited March 26, 2021 by Guest Share this post Link to post