Author Topic: dcl-ImageList-SetAt  (Read 1197 times)

velasquez

  • Sr. Member
  • ****
  • Posts: 489
dcl-ImageList-SetAt
« on: May 25, 2017, 05:58:09 AM »
Can you please show an example to work with dcl-ImageList-SetAt?

Thanks.

roy_043

  • Sr. Member
  • ****
  • Posts: 352
Re: dcl-ImageList-SetAt
« Reply #1 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)
)

velasquez

  • Sr. Member
  • ****
  • Posts: 489
Re: dcl-ImageList-SetAt
« Reply #2 on: May 27, 2017, 04:30:28 AM »
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

  • Sr. Member
  • ****
  • Posts: 489
Re: dcl-ImageList-SetAt
« Reply #3 on: March 08, 2019, 01:06:23 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

  • Sr. Member
  • ****
  • Posts: 352
Re: dcl-ImageList-SetAt
« Reply #4 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.

owenwengerd

  • Administrator
  • Hero Member
  • *****
  • Posts: 2991
    • Outside The Box
Re: dcl-ImageList-SetAt
« Reply #5 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.

velasquez

  • Sr. Member
  • ****
  • Posts: 489
Re: dcl-ImageList-SetAt
« Reply #6 on: March 11, 2019, 05:39:18 AM »
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

  • Sr. Member
  • ****
  • Posts: 489
Re: dcl-ImageList-SetAt
« Reply #7 on: March 11, 2019, 05:54:15 AM »
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

  • Administrator
  • Hero Member
  • *****
  • Posts: 2991
    • Outside The Box
Re: dcl-ImageList-SetAt
« Reply #8 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.

velasquez

  • Sr. Member
  • ****
  • Posts: 489
Re: dcl-ImageList-SetAt
« Reply #9 on: March 12, 2019, 04:32:40 AM »
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.