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
 ObjUserData with IEV_NEXT_INSERTED_OBJECT
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

c.basso

Italy
36 Posts

Posted - Jun 23 2015 :  12:11:19  Show Profile  Reply
Hi,
after seeing UserDataVect demo,
I'm trying to put data on my next inserted object,
like this:

>> This is my user data
type
TMyData=record
text1:string[255];
text2:string[255];
end;
PMyData=^TMyData;

>> On my button click event
GetMem(vUserData, SizeOf(tmydata));
vUserData^.text1:= 'hello';
vUserData^.text2:= 'hello';
ctrlImageEnVect.ObjUserData[IEV_NEXT_INSERTED_OBJECT]:= vUserData;
ctrlImageEnVect.ObjUserDataLength[IEV_NEXT_INSERTED_OBJECT]:= SizeOf(TMydata);
ctrlImageEnVect.MouseInteract:= [];
ctrlImageEnVect.MouseInteractVt:= [miPutLine];
ctrlImageEnVect.Cursor:= crIEPencil;

>> On my AfterDrawObject event
var
vUserData: PMyData;
begin
vUserData:= ctrlImageEnVect.ObjUserData[hobj];
if (vUserData <> nil) then
begin
>>> NEVER FIRED, vUserData is always nil
end;

What I'm doing wrong?

Thanks

Claudio

klausdoege

Germany
389 Posts

Posted - Jun 24 2015 :  04:45:59  Show Profile  Reply
Hi,

have you create a new Object ?
with: ImageEnVect.AddNewObject;


Klaus
www.klausdoege.de
Go to Top of Page

c.basso

Italy
36 Posts

Posted - Jun 24 2015 :  04:50:49  Show Profile  Reply
When I must create the object?

The object is created using mouse, as:
ctrlImageEnVect.MouseInteractVt:= [miPutLine];

I expect that using IEV_NEXT_INSERTED_OBJECT,
after the user creates the line with mouse,
in AfterDrawObject the object must have the userdata.

It's not like this?

Claudio
Go to Top of Page

xequte

38510 Posts

Posted - Jun 24 2015 :  22:27:18  Show Profile  Reply
Hi

I'm not sure this is the best way to do it as there is real risk of memory leak. You would be better to set it in the OnNewObject event.


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: