Delphi 2010 forms shows on "wrong" monitor
Asked Answered
C

1

7

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??

Cosmopolitan answered 9/5, 2013 at 12:12 Comment(0)
C
12

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.

Cosmopolitan answered 9/5, 2013 at 12:36 Comment(1)
You should give this answer the green check mark because it is correct.Sparling

© 2022 - 2024 — McMap. All rights reserved.