6

Quite a simple one i would think, but i need to be able to Maximize a form to a particular screen. Cant seem to find any Delphi specific info.

I can remember the forms position over subsequent application loads. However, when i restore the position, then call WindowState := wsMaximized, the form moves to the other screen! (i do have other forms also visible on that screen - it appears its maximizing to the 'active screen')

So i need a function like so:

procedure Maximize(const aScreenIndex : Integer);
begin
 if aScreenIndex < Screen.MonitorCount then
   //Maximize to that screen
end;

2 Answers 2

5

Intercept the WM_GETMINMAXINFO message and adjust the coordinates inside its MINMAXINFO structure as needed.

Sign up to request clarification or add additional context in comments.

Comments

2

Set Form.Position to poDesigned at design time In Form.FormShow or your Maximize procedure:

procedure Maximize(const aScreenIndex : Integer);
begin
  if aScreenIndex < Screen.MonitorCount then
  begin 
   //Maximize to that screen
    Myform.Left := screen.Monitors[aScreenIndex ].Left;
    Myform.WindowState := wsMaximized;
  end; 
end;

1 Comment

Genius! This solves the how to position a form in a additional monitor problem although in a maximized form. The problem had something to do with hide/show and this solved it as I put the medicine in onShow of the form.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.