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
 ImageEnVect ObjectUserData Unicode Issue

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
andyhill Posted - May 24 2017 : 20:31:55
I have been using code given to me by Nigel that works fine with non Unicode text.

My problem is I want to use Unicode text and it appears that the whole pointer concept fails to work with Unicode.

Please advise - Thanks in advance.

type
  TMyData = record
    Group: Integer;
    Name: String[100];
    Description: String[255];
    Tag: Boolean;
  end;
  PMyData = ^TMyData;

…

MyFetchData: PMyData;
MyDataArray: array of PMyData;

…

GetMem(MyFetchData, SizeOf(TMyData)); // Freed by me on close

…

  SetLength(MyDataArray, Length(MyDataArray)+1); // Set to zero length by me on close
  GetMem(MyDataArray[High(MyDataArray)], SizeOf(TMyData)); // Auto-Freed by ImageEn
  MyDataArray[High(MyDataArray)]^.Group:= 0;
  MyDataArray[High(MyDataArray)]^.Name:= IntToStr(ihObj);
  MyDataArray[High(MyDataArray)]^.Description:= '';
  ievFront.ObjUserData[ihObj]:= MyDataArray[High(MyDataArray)];
  ievFront.ObjUserDataLength[ihObj]:= SizeOf(TMyData);

…

MyFetchData:= ievFront.ObjUserData[hobj];

MyFetchData.Description returns ????????????????????????????????????????????????????????????


Andy
3   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - May 28 2017 : 15:32:08
Hi Andy

Every call to GetMem will return a unique block of memory, so the array is not needed.

However you are correct about String[255], as that will actually give you an Ansi string. Try replacing it with a fixed array of (Unicode) chars, e.g

Description: array[0..254] of Char;

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
andyhill Posted - May 25 2017 : 21:53:00
Nigel, I have about 3000 Polygon Objects each with their own ObjUserData, that is why I used an array so that the memory locations would not be merged, I will drop the array as you indicate this will not be a problem.

I need to handle Unicode which you have not addressed.

The very fact that you use a byte counter for your strings (String[255]) to me makes me think it uses bytes not Unicode WideChars. That is why we get ? as one byte cannot represent a Unicode WideChar.

Please show me how to work with Unicode in ObjUserData.

Andy
xequte Posted - May 25 2017 : 06:11:40
Hi Andy

Why are you creating MyFetchData? It does not need to be created if you are just reading from memory as here:

MyFetchData := ievFront.ObjUserData[hobj];

Also, what is the purpose of MyDataArray?

Your code should be something like:

type
  TMyData = record
    Group: Integer;
    Name: String[100];
    Description: String[255];
    Tag: Boolean;
  end;
  PMyData = ^TMyData;

…
var
  MyData: PMyData; 
begin
  GetMem(MyData, SizeOf(TMyData)); // Auto-Freed by ImageEn
  MyData^.Group:= 0;
  MyData^.Name:= IntToStr(ihObj);
  MyData^.Description:= '';
  ievFront.ObjUserData[ihObj]:= MyData;
  ievFront.ObjUserDataLength[ihObj]:= SizeOf(TMyData);

…
var
  MyFetchData: PMyData; 
begin
  MyFetchData:= ievFront.ObjUserData[hobj];
  ShowMessage( MyFetchData^.Description );


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com