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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Programmatically select an object
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

sani

Haiti
2 Posts

Posted - Nov 16 2012 :  05:19:45  Show Profile  Reply
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);

klausdoege

Germany
389 Posts

Posted - Nov 17 2012 :  11:24:49  Show Profile  Reply
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
Go to Top of Page

w2m

USA
1990 Posts

Posted - Nov 17 2012 :  13:27:54  Show Profile  Reply
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
Go to Top of Page

sani

Haiti
2 Posts

Posted - Nov 20 2012 :  01:44:46  Show Profile  Reply
Thanks for the answers.

w2m

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

Thanks
Go to Top of Page

w2m

USA
1990 Posts

Posted - Nov 20 2012 :  07:09:38  Show Profile  Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: