Quote
In article <8EF06D58Cjpedersentecho...@207.105.83.62>, Jacob Pedersen wrote:
> always a knight to the rescue. However your code doesn't work for me.
> The form is not placed with (Left, Top) begining at the mainforms client
> space.
Jacob, i must have been half asleep when i posted that code. Try this slightly
modified version:
procedure TFormX.FormCreate(Sender: TObject);
Var
r: TRect;
client: HWND;
Begin
client := application.mainform.clienthandle;
Windows.GetClientRect( client, r );
MapWindowPoints( client, HWND_DESKTOP, r, 2 );
BoundsRect := r;
End;
Quote
> Another nice thing would be if I created another instance of the form, if
> should be placed at the same point only alittle off (Left+16, Top+16), like
> cascading windows.
Well, you need to keep track of the number of forms already created and just
correct the R rectangle used in the function before you assign it to
boundsRect. One simple solution would be to place a integer variable into a
Var section in the forms unit, e.g.
Var
formcount: Integer = 0;
Placed after the Uses clause in the Implementation section this var will only
be visible for the form itself, but that is enough. There is a serious Z-order
problem with your scheme, however, since the forms are not parented to the
main form. Every time you click on a main form toolbar button or do something
with the main forms menu the main form will come to front and hide your
secondary form. To fix that use something like this in the onCreate handler of
the secondary forms:
Var
formcount: Integer = 0;
procedure TForm2.FormCreate(Sender: TObject);
Var
r: TRect;
client: HWND;
Begin
client := application.mainform.clienthandle;
Windows.GetClientRect( client, r );
MapWindowPoints( client, HWND_DESKTOP, r, 2 );
OffsetRect( r, 16*formcount, 16*formcount );
BoundsRect := r;
Inc( formcount );
SetWindowLong( handle, GWL_HWNDPARENT,
Application.Mainform.Handle );
end;
Peter Below (TeamB) 100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Sent using Virtual Access 5.00 - download your freeware copy now
http://www.atlantic-coast.com/downloads/vasetup.exe