Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread TForm ShowModal at a specified position on the screen
Thu, Feb 8 2018 10:25 PMPermanent Link

Paul Coshott

Avatar

Hi All,

I have a label that can be clicked to add a job to the day schedule (this dynamically adds a new TBasicPanel to a parent TBasicPanel).

I will be displaying a form using ShowModal. I'd like to position it based on the position of the label, so it looks a bit like a drop down to the label.

What do I need, position wise, to be able to position the search screen in relation to the label that was clicked? I want it to look a bit like a drop down.

Cheers,
Paul
Fri, Feb 9 2018 4:24 AMPermanent Link

Matthew Jones

Paul Coshott wrote:

> I will be displaying a form using ShowModal. I'd like to position it based on the position of the label, so it looks a bit like a drop down to the label.
>
> What do I need, position wise, to be able to position the search screen in relation to the label that was clicked? I want it to look a bit like a drop down.

There is no problem with doing this, other than determining the left/top location. Depending on your code, that might just be taking the .left of the label, or it might be more depth needed. I have a routine to get the screen position:

function LocalToScreenTop(xControl : TControl) : Integer;
begin                                       
   Result := xControl.Top;
   while assigned(xControl.Parent) do
   begin
       xControl := xControl.Parent;
       Result := Result + xControl.Top;
   end;
end;

Obviously you also have to make sure the form's layout is not going to get in the way too.

--

Matthew Jones
Image