panJames
asked on
Position relative to screen not to parent
Hello Experts :-)
I want to open form positioned just above clicked button.
So, what I need is the position of the button itself but not relative to its parent but to the screen.
I know that I can add position of the form, position of my button's parent and button itself but
maybe there is any better way of doing it?
Thank u very much :-)
panJames
I want to open form positioned just above clicked button.
So, what I need is the position of the button itself but not relative to its parent but to the screen.
I know that I can add position of the form, position of my button's parent and button itself but
maybe there is any better way of doing it?
Thank u very much :-)
panJames
ASKER
It works fine but only for Left property.
For some mysterious reason it does not work for Top property.
This is my code:
procedure ABC
var p : TPoint;
begin
p := Point(btnAnalyse.Left + btnAnalyse.Width, btnAnalyse.Top);
p := ClientToScreen(p);
SelectAnalysisTypeForm.Lef t := p.X;
SelectAnalysisTypeForm.Top := p.Y;
if SelectAnalysisTypeForm.Sho wModal = mrOK then
begin
end;
end;
panJames
For some mysterious reason it does not work for Top property.
This is my code:
procedure ABC
var p : TPoint;
begin
p := Point(btnAnalyse.Left + btnAnalyse.Width, btnAnalyse.Top);
p := ClientToScreen(p);
SelectAnalysisTypeForm.Lef
SelectAnalysisTypeForm.Top
if SelectAnalysisTypeForm.Sho
begin
end;
end;
panJames
and what about this?
Point(btnAnalyse.Left + btnAnalyse.Width, btnAnalyse.Top + btnAnalyse.Width);
ziolko.
Point(btnAnalyse.Left + btnAnalyse.Width, btnAnalyse.Top + btnAnalyse.Width);
ziolko.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
this change:
Point(btnAnalyse.Left + btnAnalyse.Width, btnAnalyse.Top + btnAnalyse.Height);
made my form appear lower by only btnAnalyse.Height value.
My form always appears on the top of the screen even when button clicked is rather close to the bottom of the screen.
panJames
Point(btnAnalyse.Left + btnAnalyse.Width, btnAnalyse.Top + btnAnalyse.Height);
made my form appear lower by only btnAnalyse.Height value.
My form always appears on the top of the screen even when button clicked is rather close to the bottom of the screen.
panJames
ASKER
I have an idea...
Maybe ClientToScreen considers as Client only parent of the button not the whole form?
The button's parent is actually a TPanel located on the bottom of the form.
Is it possible?
panJames
Maybe ClientToScreen considers as Client only parent of the button not the whole form?
The button's parent is actually a TPanel located on the bottom of the form.
Is it possible?
panJames
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I called it Panel1.clienttoscreen() and it works!
Thank u Mr ziolko :-)
And SteveBay too :-)
Thank u Mr ziolko :-)
And SteveBay too :-)
procedure TForm1.Button1Click(Sender
var p: TPoint;
begin
p := Point(Button1.Left + Button1.Width, Button1.Top + Button1.Height);
p := ClientToScreen(p);
with TForm2.Create(nil) do begin
Left := p.X;
Top := p.Y;
ShowModal;
end;
end;
ziolko.