• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

Modal form positioning

I have a project where the user calls up an options form, i would like this form to appear in a position reletive to the main form regardless of where it is on the screen.
Little help?
0
chris51179
Asked:
chris51179
  • 2
1 Solution
 
StefaanCommented:
Hi,

I think setting the Position property of the for to poMainFormCenter will make your Modal form appear centered in the MainForm wherever the main form is on the screen.

Regards,


Stefaan
0
 
kretzschmarCommented:
a sample

unit show_positioned_form_modal_u1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses
  show_positioned_form_modal_u2; //this form should be showed modal

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  with TForm2.Create(self) do
  begin
    top := edit1.ClientOrigin.y;
    left := edit1.ClientOrigin.x + edit1.Width;
    showmodal;  //is allways shown just right of edit1
    release;
  end;
end;

end.

meikl ;-)
0
 
chris51179Author Commented:
Thanks guys, setting the top and left properties acheived the effect, seems that one was just too easy for you fellas. but if i dont ask i'll never know!
0
 
chris51179Author Commented:
Fantastic response and lightning fast!!!
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now