ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 How to Click instead of drag when selecting

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
AndyColmes Posted - Jan 29 2016 : 15:11:41
Hello,

I would like to click on one point and another to make a rectangular selection instead of the usual click, hold and drag. Is this possible?

Thanks in advance.

Andy
4   L A T E S T    R E P L I E S    (Newest First)
AndyColmes Posted - Feb 15 2016 : 13:23:59
Hello Bill, sorry for the delay. I will give the code a try.

I was wrong about the FarStone. I meant to say FastStone Capture.

Andy
w2m Posted - Jan 30 2016 : 14:07:27
Where do you see click selection in Farstone? My copy of Farstone uses the default ImageEn selections?

This code is a little better than the previous code as the selection can be cleared by clicking outside of the selection and the selection may be dragged and resized as well.

 { Private declarations }
 AClickCount: Integer;
 AStartX: Integer;
 AStartY: Integer;
 AEndX: Integer;
 AEndY: Integer;

procedure TForm1.FormCreate(Sender: TObject);
begin
  ImageEnView1.MouseInteract := [miSelect];
  AClickCount := 0;
end;

procedure TForm1.ImageEnView1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
{ This allows making a selection with two mouse clicks.  Clicking outside of the selection clears the selection }
 { A selection may be moved or resized. }
begin
  if ClickSelect1.Checked then
  begin
    Inc(AClickCount);
    {If selected and clicked outside of selection then deselect}
    if (ImageEnView1.Selected) and
      (not ImageEnView1.IsPointInsideSelection(X, Y)) and (AClickCount >= 3)
    then
    begin
      ImageEnView1.DeSelect;
      AClickCount := 0;
      AStartX := -1;
      AStartY := -1;
      AEndX := -1;
      AEndY := -1;
      exit;
    end;
    if not ImageEnView1.IsPointInsideSelection(X, Y) then
    begin
      if AClickCount = 1 then
      begin
       { set point 1 }
        AStartX := X;
        AStartY := Y;
        Exit;
      end;
      if AClickCount = 2 then
      begin
        { set point 2 }
        AEndX := X;
        AEndY := Y;
        ImageEnView1.Select(AStartX, AStartY, AEndX, AEndY);
      end;
    end;
  end;
  {Note: ImageEnView1.MouseInteract must be [miSelect], otherwise cursor handling must be handled in order to have the correct cursors appear when the mouse is inside the selection or over the resizing grips.
   In addition code to drag or resize the selection must be added if MouseInteract is not [miSelect] }
end;

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
AndyColmes Posted - Jan 30 2016 : 11:16:09
Hello Bill, thank you for the code snippet. I will give it a try. I saw this feature in Farstone Capture and I thought it is very neat and easier for the user to make a selection, especially if the selecting is a difficult one.

Thanks again.

Andy
w2m Posted - Jan 29 2016 : 16:04:37
Of course ImageEn does not allow this per say, but it can be achieved. This can be awkward depending on what your goal is and I would not recommend it, but try this:

var
APoint: TPoint;
APoint2: TPoint;

procedure TForm1.FormCreate(Sender: TObject);
begin
  APoint := Point(-1,-1);
  APoint2 := Point(-1,-1);
end;

procedure TForm1.ImageEnView1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if APoint.X < 0 then
  begin
    APoint := Point(X,Y);
    exit;
  end;
  if APoint.X > 0 then
     APoint2 := Point(X,Y);
  if (SelectOnClick1.Down) and (APoint.X > 0) and (APoint2.X > 0) then
    ImageEnView1.Select(APoint.X, APoint.Y, APoint2.X, APoint2.Y);
end;

On the first click the point of the click is set. On the second click the second point is set. If the points are set then make the selection with ImageEnView1.Select. You will have to add a button or menu item to deselect I(ImageEnView1.Deselect) if you want to clear the selection, and to reset the points to allow making a subsequent selection. You will have to figure out a way to do this to enable dragging the selection after the second click. This code fragment does not allow dragging the selection.

There may be better ways to achieve this, but you will have to do it all in your own code.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development