Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi 2010 forms shows on "wrong" monitor

I have a simple test app, with one empty form, and a second containing a TButton. The button script is like this:-

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2.Show();
end;

Form2 is auto-created at startup. There's no other code at all.

When I run the app, I can press the button and Form2 appears. I can reposition/resize Form2 on the primary monitor, and then close it. If I press the Form1 button again, Form2 correctly reappears in the position it was last at. All fine so far...

However, if I position Form2 onto a secondary monitor, close it, and then press the button, then Form2 appears back on the primary monitor!

I want the form to reappear on the monitor it was last on - how can I get this behaviour??

like image 453
Roddy Avatar asked May 09 '13 12:05

Roddy


1 Answers

This is because the default value for the form's DefaultMonitor property is dmActiveForm.

Set Form2's DefaultMonitor to dmDesktop, and the problem is resolved.

like image 199
Roddy Avatar answered Nov 03 '22 23:11

Roddy