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
 Pointer to Layer

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
Andy_T_Bell Posted - Jan 20 2026 : 08:51:24
I'm using C++ Builder 12 and ImageEn 13.2.0

My app programmatically creates layers and will also change their Z order by using the LayersArrange function.

To keep track of the Layers, I use this code (modern C++):

auto layer = display->LayersAdd(ielkPolyline, 0, 0); 
auto pLayer = dynamic_cast<TIEPolylineLayer*>(display->Layers[layer]);


Here layer is the index of the layer, when it is created. pLayer is a pointer to the actual layer.

Simple question - is it safe to retain the pLayer pointer, so I can access it to change its color, etc?


My worry is the pointer might become invalid if ImageEn does some internal memory reorganisation. It doesn't seem practical, with dozens of layers, for me to use layer index numbers, which seem to change after a call to LayersArrange...

Is my approach safe?

Thanks.


Andy Bell
2   L A T E S T    R E P L I E S    (Newest First)
Andy_T_Bell Posted - Jan 21 2026 : 01:16:48
Nigel

Thanks for the clarification. Tags seem simplest to me, so that's what I'll use...

Many thanks

Andy

Andy Bell
xequte Posted - Jan 20 2026 : 17:52:20
Hi Andy

I would say that it is "risky". There are some methods in ImageEn that can replace a layer with a clone. It is not common but it can occur, so I would prefer you use a different method to identify the layer, for example, you could set the Layer Tag to an "ID" then iterate through the layers to find the relevant one.

http://www.imageen.com/help/TIELayer.Tag.html

Or its GUID:

http://www.imageen.com/help/TIELayer.Guid.html

Or something via:

http://www.imageen.com/help/TIELayer.UserData.html


Please see the example at:

http://www.imageen.com/help/TImageEnView.FindLayer.html


Nigel
Xequte Software
www.imageen.com