dcl-ImageList-SetAt

Started by velasquez · 2017-05-25 12:58 UTC · 9 replies · SMF topic #2509

Can you please show an example to work with dcl-ImageList-SetAt?

Thanks.
Try adding a new button to the Grid sample (C:\Program Files\OpenDCL Studio\ENU\Samples\):
(defun c:Grid/Dcl-1/YourButton#OnClicked ( / nme)
  (setq nme "D:\\YourPath\\YourImage.bmp")
  (dcl-ImageList-SetAt (dcl-Control-GetImageList Grid/Dcl-1/grid1) 0 nme)
  (dcl-ImageList-SetAt (dcl-Control-GetImageList Grid/Dcl-1/IC-ColImages) 0 nme)
  (dcl-ImageList-SetAt (dcl-Control-GetImageList Grid/Dcl-1/IC-Images) 0 nme)
)
author=roy_043 link=topic=2509.msg12491#msg12491 date=1495830433 wrote:
Try adding a new button to the Grid sample (C:\Program Files\OpenDCL Studio\ENU\Samples\):
(defun c:Grid/Dcl-1/YourButton#OnClicked ( / nme)
  (setq nme "D:\\YourPath\\YourImage.bmp")
  (dcl-ImageList-SetAt (dcl-Control-GetImageList Grid/Dcl-1/grid1) 0 nme)
  (dcl-ImageList-SetAt (dcl-Control-GetImageList Grid/Dcl-1/IC-ColImages) 0 nme)
  (dcl-ImageList-SetAt (dcl-Control-GetImageList Grid/Dcl-1/IC-Images) 0 nme)
)


Thanks for your help Roy.
author=roy_043 link=topic=2509.msg12491#msg12491 date=1495830433 wrote:
Try adding a new button to the Grid sample (C:\Program Files\OpenDCL Studio\ENU\Samples\):
(defun c:Grid/Dcl-1/YourButton#OnClicked ( / nme)
  (setq nme "D:\\YourPath\\YourImage.bmp")
  (dcl-ImageList-SetAt (dcl-Control-GetImageList Grid/Dcl-1/grid1) 0 nme)
  (dcl-ImageList-SetAt (dcl-Control-GetImageList Grid/Dcl-1/IC-ColImages) 0 nme)
  (dcl-ImageList-SetAt (dcl-Control-GetImageList Grid/Dcl-1/IC-Images) 0 nme)
)


Hello Roy,
I've done some testing with dcl-ImageList-SetAt following its example.
It turns out that the function does not work if the control's ImageList is empty.
For the tests I created a form with a GridControl.
Is there any reason for this or can it be a bug?

I'm working with Opendcl Studio version "9.0.1.4"

Thanks



I can confirm that issue: dcl-ImageList-SetAt does not work if the image list of a control is empty. Seems like a bug to me.
The (dcl-ImageList-SetAt) function should return an error when you pass NIL for the imagelist argument. I've fixed that now for the next build. However, otherwise the function is working as intended. The reason: creating an image list requires size of individual images, and that information is not available to (dcl-Control-GetImageList).

I could add a new (dcl-Control-CreateImageList) function, but I don't think it's much trouble to just add an arbitrary image to the control at design time so that the control will already have an imagelist at runtime.
author=roy_043 link=topic=2509.msg13147#msg13147 date=1552204427 wrote:
I can confirm that issue: dcl-ImageList-SetAt does not work if the image list of a control is empty. Seems like a bug to me.


Thanks for confirming the problem I reported.
author=owenwengerd link=topic=2509.msg13148#msg13148 date=1552272261 wrote:
The (dcl-ImageList-SetAt) function should return an error when you pass NIL for the imagelist argument. I've fixed that now for the next build. However, otherwise the function is working as intended. The reason: creating an image list requires size of individual images, and that information is not available to (dcl-Control-GetImageList).

I could add a new (dcl-Control-CreateImageList) function, but I don't think it's much trouble to just add an arbitrary image to the control at design time so that the control will already have an imagelist at runtime.


I tried to work around.
I inserted an image for control at drawing time. After I used the function (dcl-ImageList-SetAt) to replace the image of index 0 at runtime, it happens that the image size can no longer be changed at runtime.
This does not allow you to clear the control and create a new list with a different size.
That is correct, once an image list is added, the image size is fixed and cannot be changed. You must add the first image with correct size.
author=owenwengerd link=topic=2509.msg13152#msg13152 date=1552355064 wrote:
That is correct, once an image list is added, the image size is fixed and cannot be changed. You must add the first image with correct size.


Thanks for the reply Owen.
I think creating the function (dcl-Control-CreateImageList) is a good idea as it gives more freedom for the use of a single control.