dcl-ImageList-SetAt

Started by velasquez, May 25, 2017, 05:58:09 AM

Previous topic - Next topic

velasquez

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

Thanks.

roy_043

Try adding a new button to the Grid sample (C:\Program Files\OpenDCL Studio\ENU\Samples\):
Code (autolisp) Select
(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)
)

velasquez

Quote from: roy_043 on May 26, 2017, 01:27:13 PM
Try adding a new button to the Grid sample (C:\Program Files\OpenDCL Studio\ENU\Samples\):
Code (autolisp) Select
(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.

velasquez

Quote from: roy_043 on May 26, 2017, 01:27:13 PM
Try adding a new button to the Grid sample (C:\Program Files\OpenDCL Studio\ENU\Samples\):
Code (autolisp) Select
(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




roy_043

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.

owenwengerd

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.

velasquez

Quote from: roy_043 on March 09, 2019, 11:53:47 PM
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.

velasquez

Quote from: owenwengerd on March 10, 2019, 07:44:21 PM
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.

owenwengerd

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.

velasquez

Quote from: owenwengerd on March 11, 2019, 06:44:24 PM
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.