Recent

Author Topic: (Solved) selected area with rectangle  (Read 3461 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 1961
    • Lazarus and Free Pascal italian community
(Solved) selected area with rectangle
« on: July 23, 2012, 04:09:53 pm »
Who tells me how do I create a rectangle (with dotted lines) on a TImage when I select a part of? And how do I determine the coordinates of the selected area?
« Last Edit: July 27, 2012, 11:30:23 am by xinyiman »
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

KpjComp

  • Hero Member
  • *****
  • Posts: 680
Re: selected area with rectangle
« Reply #1 on: July 23, 2012, 04:17:42 pm »
So that you don't modify the TImage itself, what you can do is place a TPaintBox over the top of the TImage.  And then draw you dotted lines on the TPaintBox OnPaint event.

To make it so the user can move/size the rectangle you could place even more TPaintBox's or TShape's for the Handles, and the use the following technique to do the moving. -> http://www.lazarus.freepascal.org/index.php?topic=17356.0

xinyiman

  • Hero Member
  • *****
  • Posts: 1961
    • Lazarus and Free Pascal italian community
Re: selected area with rectangle
« Reply #2 on: July 27, 2012, 10:23:27 am »
Ok, doing a bit of evidence I think I have figured out how. I only have a doubt! How do I clean the TPaintBox riseleziono when another part of the object?!

So how can I delete the rectangles already created in TPaintBox?!
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 1961
    • Lazarus and Free Pascal italian community
Re: selected area with rectangle
« Reply #3 on: July 27, 2012, 11:08:48 am »
I understand that you have to use the property invalidated. Except that when I use it and then drawing a rectangle in succession I do not keep! I delete it. How can I do?!
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

xinyiman

  • Hero Member
  • *****
  • Posts: 1961
    • Lazarus and Free Pascal italian community
Re: selected area with rectangle
« Reply #4 on: July 27, 2012, 11:30:06 am »
I solved in this mode

          PaintBox1.Invalidate;
          PaintBox1.Refresh;
          PaintBox1.Canvas.Rectangle(x_SelIniz,y_SelIniz,x,y);
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1