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
 Programmatically select an object

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
sani Posted - Nov 16 2012 : 05:19:45
I have several objects (polygons) drawn over the image in TImageEnVect. How can I programmatically select a certain object in the component?

Something, like:

ImageEnVect.SelectObject(ObjectIndex or something);
4   L A T E S T    R E P L I E S    (Newest First)
w2m Posted - Nov 20 2012 : 07:09:38
No.. It is just an example of using the hObj... I figured it would be pointless to get an hObj, then do nothing with it.

William Miller
sani Posted - Nov 20 2012 : 01:44:46
Thanks for the answers.

w2m

Does the code
ImageEnVect1.ObjPenColor[hObj] := clRed;
indicates selection of the object?

Thanks
w2m Posted - Nov 17 2012 : 13:27:54
There is no SelectObject method, but there are at least three ways to programatically select an object, SelectObjectFromID, SelectObjectFromName, SelectObjectFromIndex:

procedure TForm1.SelectObjectFromID1Click(Sender: TObject);
var
  i: integer;
  hObj: integer;
  iID: integer;
begin
  hObj := -1;
  iID := StrToInt(InputBox('Get Object From ID', 'Enter An ID', '3'));
  for i := 0 to ImageEnVect1.ObjectsCount - 1 do
  begin
    hObj := ImageEnVect1.GetObjFromID(i);
    if ImageEnVect1.ObjID[hObj] = iID then
    begin
      ImageEnVect1.ObjPenColor[hObj] := clRed;
      break;
    end;
  end;
  if hObj = -1 then
    MessageDlg('Object With An ID of ' + IntToStr(iID) + ' was not found', mtWarning, [mbOK], 0);
end;

procedure TForm1.SelectObjectFromIndex1Click(Sender: TObject);
var
  i: integer;
  hObj: integer;
  iIndex: integer;
begin
  hObj := -1;
  iIndex := StrToInt(InputBox('Get Object From Index', 'Enter An Index', '1'));
  for i := 0 to ImageEnVect1.ObjectsCount - 1 do
  begin
    hObj := ImageEnVect1.GetObjFromIndex(i);
    if hObj = iIndex then
    begin
      ImageEnVect1.ObjPenColor[hObj] := clRed;
      break;
    end;
  end;
  if hObj = -1 then
    MessageDlg('Object With An Index of ' + IntToStr(iIndex) + ' was not found', mtWarning,
      [mbOK], 0);
end;

procedure TForm1.SelectObjectFromName1Click(Sender: TObject);
var
  i: integer;
  hObj: integer;
  iName: string;
begin
  hObj := -1;
  iName := InputBox('Get Object From Name', 'Enter An Name', 'Ellipse');
  for i := 0 to ImageEnVect1.ObjectsCount - 1 do
  begin
    hObj := ImageEnVect1.GetObjFromName(AnsiString(iName));
    if ImageEnVect1.ObjName[hObj] = AnsiString(iName) then
    begin
      ImageEnVect1.ObjPenColor[hObj] := clRed;
      break;
    end;
  end;
  if hObj = -1 then
    MessageDlg('Object With An Name of ' + iName + ' was not found', mtWarning, [mbOK],
      0);
end;

William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
klausdoege Posted - Nov 17 2012 : 11:24:49
Hello Sani,
selectobject (?), there is not.
But I think this also goes.

Example:
myobj=4;
ImageEnVect.SelAllObjects;
for hobj := 0 to ImageEnVect.SelObjectsCount-1 do
begin
if hobj<>myobj then ImageEnVect.UnSelObject(hobj);
end;


Klaus
www.klausdoege.de