Reputation: 43
Hi I have a delphi application that consists of multiple forms, I would like it so that when a user clicks to open/show a new form, the new form opens with the Form.Left and Form.Top which are copied from the previous form to the new form. I tried using a Sender:TObject for this but I only have basic graphical delphi and object oriented knowledge. This is how I would have to do it each time manually for an example of opening the database form from the main menu form using an OnClick event:
MainMenuForm.Hide;
DatabaseForm.Left:=MainMenuForm.Left;
DatabaseForm.Top:=MainMenuForm.Top;
DatabaseForm.Show;
However I have multiple forms with multiple OnClick events to each form so I would have to do this with different forms each time. I know that may have sounded confusing but hopefully someone knows what I'm talking about and I know there's probably a simple solution to this problem, Thanks.
Upvotes: 0
Views: 349
Reputation: 613531
Probably the simplest is to put this in a procedure accepting two forms:
procedure ShowHideForm(OldForm, NewForm: TForm);
begin
OldForm.Hide;
NewForm.Left := OldForm.Left;
NewForm.Top := OldForm.Top;
NewForm.Show;
end;
Upvotes: 1