Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Restricting Dialog form and BasicPanel AllowMove movement
Mon, Oct 26 2015 7:55 PMPermanent Link

Trinione

Problem:
IF (and most certainly when) a user drags a dialog form or basic panel off of the screen they are then unable to access it.

Is there any way to prevent this?

What I would like to do is set Min.Top, Min.Right, Min.Bottom, Min.Left properties that would restrict directional movement accordingly.

So, I would set Min.Top := 0, so the caption bar is always visible, and the others to say Min.Left/Right/Bottom := 40; so  some amount of the form cannot be dragged off the screen.

Can this be done now?
Mon, Oct 26 2015 8:10 PMPermanent Link

Raul

Team Elevate Team Elevate

On 10/26/2015 7:55 PM, Trinione wrote:
> IF (and most certainly when) a user drags a dialog form or basic panel off of the screen they are then unable to access it.
> Is there any way to prevent this?
> What I would like to do is set Min.Top, Min.Right, Min.Bottom, Min.Left properties that would restrict directional movement accordingly.
> So, I would set Min.Top := 0, so the caption bar is always visible, and the others to say Min.Left/Right/Bottom := 40; so  some amount of the form cannot be dragged off the screen.
> Can this be done now?


You could add an OnMove event handler for the dialog and then put
something like this in it  :

procedure TdlgForm1.dlgForm1Move(Sender: TObject);
begin
   if self.left < 0 then  self.left := 0;
   if self.top < 0 then  self.top := 0;
   if self.left+self.width > Application.Surface.Width then
      self.left := Application.Surface.Width - self.width;
   if self.top+self.height > Application.Surface.height then
      self.top := Application.Surface.height -self.height;
end;


This would limit the form movement to the surface - you can allow parts
of it to be dragged outside the edge if you want of course.

Raul
Mon, Oct 26 2015 8:20 PMPermanent Link

Trinione

<< You could add an OnMove event handler for the dialog and then put
something like this in it >>


Ah! Great! Thank you very much Raul.
Mon, Oct 26 2015 8:58 PMPermanent Link

Rick

On 27/10/15 11:20, Trinione wrote:
> << You could add an OnMove event handler for the dialog and then put
> something like this in it >>
>
>
> Ah! Great! Thank you very much Raul.
>

If you prefer to be able to move beyond the surface you can add the
following to the form's OnCreate event:

Application.Surface.ScrollBars:=sbBoth;

This will activate scroll bars on the surface if the control is moved
beyond it boundaries. You may still have problems if the control is
moved too far left or up so using OnMove could be necessary.

--
Rick
Image