T O P I C R E V I E W |
c.basso |
Posted - Jun 23 2015 : 12:11:19 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 |
3 L A T E S T R E P L I E S (Newest First) |
xequte |
Posted - Jun 24 2015 : 22:27:18 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
|
c.basso |
Posted - Jun 24 2015 : 04:50:49 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 |
klausdoege |
Posted - Jun 24 2015 : 04:45:59 Hi,
have you create a new Object ? with: ImageEnVect.AddNewObject;
Klaus www.klausdoege.de |