Author |
Topic  |
|
rswyman@docuxplorer.com
  
USA
156 Posts |
Posted - Sep 07 2018 : 20:56:08
|
Hi All,
How can I set a selected region and then delete all object within that region?
Thanks Ron |
|
xequte
    
39053 Posts |
Posted - Sep 07 2018 : 22:47:47
|
Hi Ron
If EnableRangeObjectsSelection is enabled, then you can drag select objects. Iterate through the SelObjects array and remove them.
Nigel Xequte Software www.imageen.com
|
 |
|
rswyman@docuxplorer.com
  
USA
156 Posts |
Posted - Sep 08 2018 : 08:18:35
|
Hi Nigel,
I tried this but SelObjectsCount is always zero.
fImageEnVect.EnableRangeObjectsSelection := true;
fImageEnVect.Select(x, y, width, height);
for ii := 0 to fImageEnVect.SelObjectsCount -1 do begin
hObj := fImageEnVect.SelObjects[ii];
fImageEnVect.RemoveObject(hObj);
end;
|
 |
|
w2m
   
USA
1990 Posts |
Posted - Sep 08 2018 : 11:36:07
|
Set fImageEnVect.EnableRangeObjectsSelection to true before making a selection with the mouse. After you select objects with the mouse then call your procedure:
for ii := 0 to fImageEnVect.SelObjectsCount -1 do begin
hObj := fImageEnVect.SelObjects[ii];
fImageEnVect.RemoveObject(hObj);
end; This works as expected here, meaning the selected objects are removed.
Bill Miller Adirondack Software & Graphics Email: w2m@hughes.net EBook: http://www.imageen.com/ebook/ Custom Commercial ImageEn Development |
 |
|
rswyman@docuxplorer.com
  
USA
156 Posts |
Posted - Sep 08 2018 : 13:16:23
|
Thanks Bill, but this process is being executed without the mouse / user interaction but programmatically. So the question still stands, how do I select a group of objects via (x, y, width and height) / region?
|
 |
|
w2m
   
USA
1990 Posts |
Posted - Sep 08 2018 : 14:13:23
|
fImageEnVect.Select(x, y, width, height);
I think this just makes a rectangular selection rubberband and probably does not operate like selection of objects with the mouse. Unfortunately I have never tried to select objects within rectangular coordinates but you might want to search the archives to see if this is described in some post. I do not see a method to select all the objects inside of a TRect and I do not know if such a method even exists.
Try taking a look at Group/UnGroup objects in the help file. This may help but I am not sure about it.
If not then Nigel may have some ideas on how to select objects inside of a TRect or maybe even adding a method to do so. For now I guess I can not be of assistance to achieve this programmatically.
Bill Miller Adirondack Software & Graphics Email: w2m@hughes.net EBook: http://www.imageen.com/ebook/ Custom Commercial ImageEn Development |
 |
|
rswyman@docuxplorer.com
  
USA
156 Posts |
Posted - Sep 08 2018 : 15:09:43
|
Thanks for the effort Bill! |
 |
|
xequte
    
39053 Posts |
|
rswyman@docuxplorer.com
  
USA
156 Posts |
Posted - Sep 09 2018 : 08:22:48
|
Here is a sample of the final result.
aRect1.Left := x;
aRect1.Top := y;
aRect1.Right := x+width;
aRect1.Bottom := y+Height;
for ii := (fImageEnVect.ObjectsCount -1) downto 0 do begin
hobj := fImageEnVect.GetObjFromIndex(ii);
fImageEnVect.GetObjRect(hobj, aRect2);
IntersectRect(resultRect,aRect1, aRect2);
if (resultRect.Left <> 0) and (resultRect.Top <> 0) and
(resultRect.Bottom <> 0) and (resultRect.Right <> 0) then begin
fImageEnVect.RemoveObject(ii);
end;
end;
Thank You. |
 |
|
xequte
    
39053 Posts |
Posted - Sep 09 2018 : 15:25:56
|
Nice Ronald,
Note that you can also just use the boolean result of IntersectRect:
If IntersectRect(resultRect,aRect1, aRect2) then...
Nigel Xequte Software www.imageen.com
|
 |
|
rswyman@docuxplorer.com
  
USA
156 Posts |
Posted - Sep 09 2018 : 16:16:59
|
ok, thx! |
 |
|
|
Topic  |
|