Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top