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
 Pointer to Layer
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Andy_T_Bell

United Kingdom
9 Posts

Posted - Jan 20 2026 :  08:51:24  Show Profile  Reply
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

xequte

39327 Posts

Posted - Jan 20 2026 :  17:52:20  Show Profile  Reply
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
Go to Top of Page

Andy_T_Bell

United Kingdom
9 Posts

Posted - Jan 21 2026 :  01:16:48  Show Profile  Reply
Nigel

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

Many thanks

Andy

Andy Bell
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: