Reputation: 323
All the modal forms are displayed at Left Top of the screen while the setting are as Follows
BorderIcons = [biSystemMenu]
BorderStyle = bsSingle
Position = poOwnerFormCenter
Earlier it used to be display as per setting but recently i made some changes which causes the problem
Let me explain further so you can suggest appropriate solution.
My application has almost more than 50 forms and i open them as CustomerForm.Show/ShowModal. All forms are inherited from one root form which has following code to display icon on task bar
procedure TBaseForm.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.ExStyle := Params.ExStyle or WS_Ex_AppWindow;
Params.WndParent := GetDesktopwindow;
end;
There was one problem that whenever a file open or file save dialog was opened from any form(whether it is modal form or not) , Main form was coming at Top, to fix this i made a Dummy Main Form and
put Application.ShowMainForm := false;
in project file and this worked fine but this started all modal form appearing at Left Top Corner of the screen.
Can you please suggests on this?
Upvotes: 1
Views: 3469
Reputation: 1161
Add this to the create of your main form:
SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) or
WS_EX_TOPMOST);
Upvotes: 0
Reputation: 8086
As you are using the same ancestor for all your windows, you can add your own public function ShowModal with a parameter Parent: TYourForm.
In this method, you get the position of the Parent, calculate the center, and you move your modal window to its center. After, you call the real ShowModal in your own...
Upvotes: 0