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
 Help with deleting an Object in TImageEnVect

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 - Mar 17 2015 : 19:39:29
Hello,

I would like to process a new object before accepting it. I put the following code in the OnNewObject event to show a form. If the form is cancelled, then I would remove that Object, but somehow the grip handles is still showing after removing the Object.

Where did I go wrong and how do I clear the grip handles from showing?

Thanks

Andy

----------------------------------------------------------------------------

procedure TfrmColorZoneForm.ImageEnVect1NewObject(Sender: TObject;
hobj: Integer);
var
proceed: Boolean;
begin
proceed := False;

with TfrmNewZoneForm.Create( Self ) do begin
if (Showmodal = mrOK) then begin
proceed := True;
end;
end;

if (proceed = True) then begin
//Add to Grid
end else begin
ImageEnVect1.RemoveObject( hobj );
ImageEnVect1.Update;
end;
end;


13   L A T E S T    R E P L I E S    (Newest First)
AndyColmes Posted - Mar 19 2015 : 14:14:22
Bill and Nigel, thank you very much for the solutions and the demo. I really appreciate it.

Thanks again.

Andy
w2m Posted - Mar 19 2015 : 11:31:50
A demo application has been created to show how to post a message to create a new user created runtime TImageEnVect event. In this case, the runtime created event could be considered a "OnAfterNewObject event". This event is executed every time a object is added to TImageEnVect. When the "OnAfterNewObject event" is executed, a modal form appears which asks if the object should be added. If the user replies "Yes" no action is taken. If the user replies "No" the new object is removed.

http://www.xecute.com/ieforum/topic.asp?whichpage=2&TOPIC_ID=1446#7522

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
xequte Posted - Mar 18 2015 : 20:40:08
Hi Bill

Yes, sorry, your method works too.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
w2m Posted - Mar 18 2015 : 20:30:59
Posting a message would work for this as well as the way that I demonstrated. The way that is demonstrated works and has been tested using the Vectorial demo.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
xequte Posted - Mar 18 2015 : 20:19:34
Hi

Unfortunately at the point the NewObject event occurs it is still processing the object so removing it is problematic.

I think you would be better to post a custom message to the form (passing the hobj as one of the params). Then when the form receives the message it removes the object.

Here's a good example of custom messages:

http://www.cryer.co.uk/brian/delphi/howto_send_custom_window_message.htm



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
w2m Posted - Mar 18 2015 : 16:32:25
I am using ImageEn 6.0, but I have no idea if it makes any difference or not, but I suspect it doesn't.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
AndyColmes Posted - Mar 18 2015 : 16:21:08
Sorry Bill, I meant OnAfterDrawObject and not OnBeforeDrawObject. I have used your code and no other events are coded. That is why I am puzzled. I will give it more tests and see what I come up with.

Thanks again.

Andy
w2m Posted - Mar 18 2015 : 13:50:35
I think you had better backup a bit. My objects are selectable, resizable and moveable, so your app for which I have no code is causing the problem. The problem is not TImageEnVect. Take my code and add it to the vectorial demo.. From there you can see what is wrong with your app...

You said you removed the code from OnBeforeDrawObject and OnNewObject events, and the Objects were moveable and resizable.... so that is where your problem is unless you are using a lot of different events for which I have no idea.

My code does not even have a OnBeforeDrawObject Event and the OnNewObject event only sets the global AHobj and ACancelObjectCreation initial values then shows the Form, so that is not the problem.

I am guessing your problem is in the OnBeforeDrawObject event or you have added additional code to the OnNewObject or other events.

Take a breath and start with the Vectorial demo with my code than add that to your app when you get it working.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
AndyColmes Posted - Mar 18 2015 : 12:07:08
Hi Bill, if I remove the code from OnBeforeDrawObject and OnNewObject events, the Object is moveable and resizeable. So, I think the code in those events cause the issue but I have no idea why.

Andy
AndyColmes Posted - Mar 18 2015 : 11:33:12
Unfortunately, I do have to worry about it. Your code helped a lot and it worked. But when Form1.Showmodal = mrOK, and ACanceObjectCreation is False, the Object stays which is supposed to be, but it is not moveable or resizeable.

I had set this in my FormShow but it does not seem to help.

ImageEnVect1.ObjStyle[ -1 ] := [ievsVisible, ievsSelectable, ievsMoveable, ievsSizeable];

Can you verify if it is the same for you?

Thanks again Bill.

Andy

w2m Posted - Mar 18 2015 : 11:16:13
Without seeing the code it is not possible to give more advice... Anyway you do not have to worry about it now.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
AndyColmes Posted - Mar 18 2015 : 11:07:49
Thanks very much Bill. I will give it a try. I also noticed that the Object created, a rectangle in this case, cannot be resized or moved. After the Object is created (or deleted), I set the MoustInteractVT to [ miObjectSelect ], but my Object cannot be resized or moved. I did set the ObjStyle to include [ ievsVisible, ievsSelectable, ievsMoveable, ievsSizeable ] in the OnNewObject event as well as in my FormShow by setting ObjStyle[ -1 ] to include all the above, but it didn't help.

Where did I go wrong?

Andy
w2m Posted - Mar 18 2015 : 09:20:24
With your code after the object is removed, it not only still has handles, the object can be selected despite the object count being 0. Perhaps this is a bug in ImageEnVect or it is just not possible to remove the object until it is fully created. It is possible that the object is not fully created until the NewObject event ends.

I managed to achieve what you are looking for in a different way by of waiting until the object is fully created before removing it.

public
  { Public declarations }
  AHobj: Integer;
  ACancelObjectCreation: boolean;
 end;

procedure TMainForm.FormCreate(Sender: TObject);
begin
  AHobj := -1;
  ACancelObjectCreation := False;
end;

procedure TMainForm.ImageEnVect1AfterDrawObject(Sender: TObject; hobj: Integer;
  destination: TIEBitmap; destCanvas: TIECanvas; destRect: TRect;
  drawingAlpha: Boolean; var handled: Boolean);
var
  q: Integer;
begin
  for q := -1 to ImageEnVect1.SelObjectsCount - 1 do
  begin
    if q >= 0 then
      AHobj := ImageEnVect1.SelObjects[q];
    ImageEnVect1.Update;
    break;
  end;
  if (ACancelObjectCreation) and (AHobj > -1) then
  begin
    ImageEnVect1.RemoveObject(AHobj);
    ImageEnVect1.Update;
    if AHobj = 0 then
      ImageEnVect1.DeSelect;
    AHobj := -1;
  end;
end;

procedure TMainForm.ImageEnVect1NewObject(Sender: TObject; hobj: Integer);
begin
  AHobj := hobj;
  ACancelObjectCreation := False;
  Form1.ShowModal;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if ModalResult = mrCancel then
    MainForm.ACancelObjectCreation := True
  else
    MainForm.ACancelObjectCreation := False;
end;

There may be a better way to achieve this but this works with the vectorial demo.

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