Hi,

My front end has a Tshape(Cirle) Over a Panel and I am trying to move the circle on the panel and get the X and Y values and send these values through comport for serial communication.

However I am able to retrieve the values but the shape is flickering when I move it over the panel and it finally disappears.I am having the shape at the center of the 120*120 panel and having the center of the shape as 0*0. When I move the shape towards the left I should be getting -60 to 0 and towards right 0 to 60, similarly for the Y axis. And the shape should stay at the position where I left it through the mouse move.

Any Help greatly appreciated.

Regards

Show your code. Hard to guess your problem without it.

Show your code. Hard to guess your problem without it.

procedure TForm4.Shape1MouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);

//Shape is placed on the panel with width and top as 120*120
  var
  int1: integer;
  int2: integer;
begin

if ssleft in shift then
begin

  int1:= shape1.Left;
  int2:= shape1.Top;

  pitchedit.Text:= inttostr(int1+X);
  rolledit.Text:= inttostr(int2+Y);
  Shape1.Left:= int1+X;
  Shape1.Top:= int2+Y;

end;
end;

Hey..Now I am able to move the shape over the panel smoothly but it is however having the top left of the panel as zero reference point, how do I make it have the center of the TShape as 0*0

Shift the coordinates with half the width and half the height.

Hi, below is the code to have the shape move over the panel on mouse click over it, but could you please let me know how to limit the shape to just move around the panel and not out of it. Now I am able to move it outside the panel even though it is not visible outside, the value changes in the edit box.

procedure TInteractiveP.Shape1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);

var
 rl1, rl2 : Real;

begin
  if ssleft in shift then
    begin
      rl1:= shape1.Left+X/10;
      rl2:= shape1.Top+Y/10;
    if(rl1> 60) then
      begin
        rl1:= 60-rl1;
        pitchedit.Text:= floattostr(rl1);
        Statusbar1.Panels[0].Text:= 'Pitch Value is '+ floattostr(rl1);
      end
    else
      pitchedit.Text:= floattostr(rl1);
      Statusbar1.Panels[0].Text:= 'Pitch Value is '+ floattostr(rl1);
      if (rl2> 60) then
        begin
          rl2:= 60-rl2;
          rolledit.Text:= floattostr(rl2);
          Statusbar1.panels[1].Text:= 'Roll Value is '+ floattostr(rl2);
        end
      else
        rolledit.Text:= floattostr(rl2);
        Statusbar1.Panels[1].Text:= 'Roll Value is '+ floattostr(rl2);
        Shape1.Left:= trunc(shape1.left+X/10);
        Shape1.Top:= trunc(shape1.top+Y/10);
      end;
end;

When you assign a new left and top, you can check whether or not it falls of the panel. If so, do not update the left and top.

Thank you...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.