Skip to main content

[archive] Loading pictures

  • November 25, 2010
  • 7 replies
  • 0 views

[Migrated content. Thread originally posted on 24 November 2010]

I don't want to distribute bitmaps with my application, and if I add bitmaps to buttons, forms, etc. then I don't have to. However, I have a couple of bitmaps I want to use on active-x components so I need to load them with the CALL "W$BITMAP" USING WBITMAP-LOAD-PICTURE routine. The following code works 100% and I have access to the images when using acuthin.exe, but does not work when run with wrun32.exe it falls into the WBERR-FILE-ERROR. Is there something I need to do differently when run under wrun32 or could this just be a bug that I need to report?


       COPY RESOURCE "MyPic.bmp".
       77  IMAGE-HANDLE        HANDLE OF IPictureDisp.
       77  IMAGE-ERROR          REDEFINES IMAGE-HANDLE PIC S9(9) COMP-5.

           CALL "W$BITMAP" USING WBITMAP-LOAD-PICTURE, "MyPic.bmp"
           GIVING IMAGE-HANDLE.
           EVALUATE IMAGE-ERROR
               WHEN WBERR-FILE-ERROR
                  DISPLAY MESSAGE BOX
                    "File not found"
                    TITLE "Error"
                    INITIALIZE IMAGE-HANDLE
               WHEN WBERR-FORMAT-UNSUPPORTED
                  DISPLAY MESSAGE BOX
                    "Format not supported"
                     TITLE "Error"
                     INITIALIZE IMAGE-HANDLE
               WHEN OTHER
                    DISPLAY MESSAGE BOX
                    "File successfully loaded"
                    TITLE "Success"
           END-EVALUATE.

7 replies

[Migrated content. Thread originally posted on 24 November 2010]

I don't want to distribute bitmaps with my application, and if I add bitmaps to buttons, forms, etc. then I don't have to. However, I have a couple of bitmaps I want to use on active-x components so I need to load them with the CALL "W$BITMAP" USING WBITMAP-LOAD-PICTURE routine. The following code works 100% and I have access to the images when using acuthin.exe, but does not work when run with wrun32.exe it falls into the WBERR-FILE-ERROR. Is there something I need to do differently when run under wrun32 or could this just be a bug that I need to report?


       COPY RESOURCE "MyPic.bmp".
       77  IMAGE-HANDLE        HANDLE OF IPictureDisp.
       77  IMAGE-ERROR          REDEFINES IMAGE-HANDLE PIC S9(9) COMP-5.

           CALL "W$BITMAP" USING WBITMAP-LOAD-PICTURE, "MyPic.bmp"
           GIVING IMAGE-HANDLE.
           EVALUATE IMAGE-ERROR
               WHEN WBERR-FILE-ERROR
                  DISPLAY MESSAGE BOX
                    "File not found"
                    TITLE "Error"
                    INITIALIZE IMAGE-HANDLE
               WHEN WBERR-FORMAT-UNSUPPORTED
                  DISPLAY MESSAGE BOX
                    "Format not supported"
                     TITLE "Error"
                     INITIALIZE IMAGE-HANDLE
               WHEN OTHER
                    DISPLAY MESSAGE BOX
                    "File successfully loaded"
                    TITLE "Success"
           END-EVALUATE.

the only different i see.

we use wbitmap-load not wbitmap-load-picture and use the full path to the image, not only the image name.

[Migrated content. Thread originally posted on 24 November 2010]

I don't want to distribute bitmaps with my application, and if I add bitmaps to buttons, forms, etc. then I don't have to. However, I have a couple of bitmaps I want to use on active-x components so I need to load them with the CALL "W$BITMAP" USING WBITMAP-LOAD-PICTURE routine. The following code works 100% and I have access to the images when using acuthin.exe, but does not work when run with wrun32.exe it falls into the WBERR-FILE-ERROR. Is there something I need to do differently when run under wrun32 or could this just be a bug that I need to report?


       COPY RESOURCE "MyPic.bmp".
       77  IMAGE-HANDLE        HANDLE OF IPictureDisp.
       77  IMAGE-ERROR          REDEFINES IMAGE-HANDLE PIC S9(9) COMP-5.

           CALL "W$BITMAP" USING WBITMAP-LOAD-PICTURE, "MyPic.bmp"
           GIVING IMAGE-HANDLE.
           EVALUATE IMAGE-ERROR
               WHEN WBERR-FILE-ERROR
                  DISPLAY MESSAGE BOX
                    "File not found"
                    TITLE "Error"
                    INITIALIZE IMAGE-HANDLE
               WHEN WBERR-FORMAT-UNSUPPORTED
                  DISPLAY MESSAGE BOX
                    "Format not supported"
                     TITLE "Error"
                     INITIALIZE IMAGE-HANDLE
               WHEN OTHER
                    DISPLAY MESSAGE BOX
                    "File successfully loaded"
                    TITLE "Success"
           END-EVALUATE.

ya the difference between WBITMAP-LOAD and WBITMAP-LOAD-PICTURE is one will give you an ACU Handle and the other will give you the IPictureDisp (windows) handle.

When you say you use the full path, do you mean:
COPY RESOURCE "C:\\myacuproject\\resource\\MyPic.bmp".
CALL "W$BITMAP" USING WBITMAP-LOAD, "C:\\myacuproject\\resource\\MyPic.bmp".

[Migrated content. Thread originally posted on 24 November 2010]

I don't want to distribute bitmaps with my application, and if I add bitmaps to buttons, forms, etc. then I don't have to. However, I have a couple of bitmaps I want to use on active-x components so I need to load them with the CALL "W$BITMAP" USING WBITMAP-LOAD-PICTURE routine. The following code works 100% and I have access to the images when using acuthin.exe, but does not work when run with wrun32.exe it falls into the WBERR-FILE-ERROR. Is there something I need to do differently when run under wrun32 or could this just be a bug that I need to report?


       COPY RESOURCE "MyPic.bmp".
       77  IMAGE-HANDLE        HANDLE OF IPictureDisp.
       77  IMAGE-ERROR          REDEFINES IMAGE-HANDLE PIC S9(9) COMP-5.

           CALL "W$BITMAP" USING WBITMAP-LOAD-PICTURE, "MyPic.bmp"
           GIVING IMAGE-HANDLE.
           EVALUATE IMAGE-ERROR
               WHEN WBERR-FILE-ERROR
                  DISPLAY MESSAGE BOX
                    "File not found"
                    TITLE "Error"
                    INITIALIZE IMAGE-HANDLE
               WHEN WBERR-FORMAT-UNSUPPORTED
                  DISPLAY MESSAGE BOX
                    "Format not supported"
                     TITLE "Error"
                     INITIALIZE IMAGE-HANDLE
               WHEN OTHER
                    DISPLAY MESSAGE BOX
                    "File successfully loaded"
                    TITLE "Success"
           END-EVALUATE.

As Mikalodean points out, there is a difference to the two. While WBITMAP-LOAD is entirely a runtime interal function and adheres to the file logic of the runtime, the WBITMAP-LOAD-PICTURE is using a Windows API COM service to load and instantiate the file as an object. We have no control of how that function load a file, thus the requirement for an absolute path.

[Migrated content. Thread originally posted on 24 November 2010]

I don't want to distribute bitmaps with my application, and if I add bitmaps to buttons, forms, etc. then I don't have to. However, I have a couple of bitmaps I want to use on active-x components so I need to load them with the CALL "W$BITMAP" USING WBITMAP-LOAD-PICTURE routine. The following code works 100% and I have access to the images when using acuthin.exe, but does not work when run with wrun32.exe it falls into the WBERR-FILE-ERROR. Is there something I need to do differently when run under wrun32 or could this just be a bug that I need to report?


       COPY RESOURCE "MyPic.bmp".
       77  IMAGE-HANDLE        HANDLE OF IPictureDisp.
       77  IMAGE-ERROR          REDEFINES IMAGE-HANDLE PIC S9(9) COMP-5.

           CALL "W$BITMAP" USING WBITMAP-LOAD-PICTURE, "MyPic.bmp"
           GIVING IMAGE-HANDLE.
           EVALUATE IMAGE-ERROR
               WHEN WBERR-FILE-ERROR
                  DISPLAY MESSAGE BOX
                    "File not found"
                    TITLE "Error"
                    INITIALIZE IMAGE-HANDLE
               WHEN WBERR-FORMAT-UNSUPPORTED
                  DISPLAY MESSAGE BOX
                    "Format not supported"
                     TITLE "Error"
                     INITIALIZE IMAGE-HANDLE
               WHEN OTHER
                    DISPLAY MESSAGE BOX
                    "File successfully loaded"
                    TITLE "Success"
           END-EVALUATE.

As Mikalodean points out, there is a difference to the two. While WBITMAP-LOAD is entirely a runtime interal function and adheres to the file logic of the runtime, the WBITMAP-LOAD-PICTURE is using a Windows API COM service to load and instantiate the file as an object. We have no control of how that function load a file, thus the requirement for an absolute path.

[Migrated content. Thread originally posted on 24 November 2010]

I don't want to distribute bitmaps with my application, and if I add bitmaps to buttons, forms, etc. then I don't have to. However, I have a couple of bitmaps I want to use on active-x components so I need to load them with the CALL "W$BITMAP" USING WBITMAP-LOAD-PICTURE routine. The following code works 100% and I have access to the images when using acuthin.exe, but does not work when run with wrun32.exe it falls into the WBERR-FILE-ERROR. Is there something I need to do differently when run under wrun32 or could this just be a bug that I need to report?


       COPY RESOURCE "MyPic.bmp".
       77  IMAGE-HANDLE        HANDLE OF IPictureDisp.
       77  IMAGE-ERROR          REDEFINES IMAGE-HANDLE PIC S9(9) COMP-5.

           CALL "W$BITMAP" USING WBITMAP-LOAD-PICTURE, "MyPic.bmp"
           GIVING IMAGE-HANDLE.
           EVALUATE IMAGE-ERROR
               WHEN WBERR-FILE-ERROR
                  DISPLAY MESSAGE BOX
                    "File not found"
                    TITLE "Error"
                    INITIALIZE IMAGE-HANDLE
               WHEN WBERR-FORMAT-UNSUPPORTED
                  DISPLAY MESSAGE BOX
                    "Format not supported"
                     TITLE "Error"
                     INITIALIZE IMAGE-HANDLE
               WHEN OTHER
                    DISPLAY MESSAGE BOX
                    "File successfully loaded"
                    TITLE "Success"
           END-EVALUATE.

As Mikalodean points out, there is a difference to the two. While WBITMAP-LOAD is entirely a runtime interal function and adheres to the file logic of the runtime, the WBITMAP-LOAD-PICTURE is using a Windows API COM service to load and instantiate the file as an object. We have no control of how that function load a file, thus the requirement for an absolute path.

[Migrated content. Thread originally posted on 24 November 2010]

I don't want to distribute bitmaps with my application, and if I add bitmaps to buttons, forms, etc. then I don't have to. However, I have a couple of bitmaps I want to use on active-x components so I need to load them with the CALL "W$BITMAP" USING WBITMAP-LOAD-PICTURE routine. The following code works 100% and I have access to the images when using acuthin.exe, but does not work when run with wrun32.exe it falls into the WBERR-FILE-ERROR. Is there something I need to do differently when run under wrun32 or could this just be a bug that I need to report?


       COPY RESOURCE "MyPic.bmp".
       77  IMAGE-HANDLE        HANDLE OF IPictureDisp.
       77  IMAGE-ERROR          REDEFINES IMAGE-HANDLE PIC S9(9) COMP-5.

           CALL "W$BITMAP" USING WBITMAP-LOAD-PICTURE, "MyPic.bmp"
           GIVING IMAGE-HANDLE.
           EVALUATE IMAGE-ERROR
               WHEN WBERR-FILE-ERROR
                  DISPLAY MESSAGE BOX
                    "File not found"
                    TITLE "Error"
                    INITIALIZE IMAGE-HANDLE
               WHEN WBERR-FORMAT-UNSUPPORTED
                  DISPLAY MESSAGE BOX
                    "Format not supported"
                     TITLE "Error"
                     INITIALIZE IMAGE-HANDLE
               WHEN OTHER
                    DISPLAY MESSAGE BOX
                    "File successfully loaded"
                    TITLE "Success"
           END-EVALUATE.

As Mikalodean points out, there is a difference to the two. While WBITMAP-LOAD is entirely a runtime interal function and adheres to the file logic of the runtime, the WBITMAP-LOAD-PICTURE is using a Windows API COM service to load and instantiate the file as an object. We have no control of how that function load a file, thus the requirement for an absolute path.


I'm curious as to why it works under thin client tho? And I wonder why the fuction WBITMAP-LOAD-IMAGELIST does not require an absolute path (it's handled in the exact same fashion as the WBITMAP-LOAD routine). It also most likely instantiates the file as an object using the windows API.

I dunno, it's not very consistent if you ask me.

[Migrated content. Thread originally posted on 24 November 2010]

I don't want to distribute bitmaps with my application, and if I add bitmaps to buttons, forms, etc. then I don't have to. However, I have a couple of bitmaps I want to use on active-x components so I need to load them with the CALL "W$BITMAP" USING WBITMAP-LOAD-PICTURE routine. The following code works 100% and I have access to the images when using acuthin.exe, but does not work when run with wrun32.exe it falls into the WBERR-FILE-ERROR. Is there something I need to do differently when run under wrun32 or could this just be a bug that I need to report?


       COPY RESOURCE "MyPic.bmp".
       77  IMAGE-HANDLE        HANDLE OF IPictureDisp.
       77  IMAGE-ERROR          REDEFINES IMAGE-HANDLE PIC S9(9) COMP-5.

           CALL "W$BITMAP" USING WBITMAP-LOAD-PICTURE, "MyPic.bmp"
           GIVING IMAGE-HANDLE.
           EVALUATE IMAGE-ERROR
               WHEN WBERR-FILE-ERROR
                  DISPLAY MESSAGE BOX
                    "File not found"
                    TITLE "Error"
                    INITIALIZE IMAGE-HANDLE
               WHEN WBERR-FORMAT-UNSUPPORTED
                  DISPLAY MESSAGE BOX
                    "Format not supported"
                     TITLE "Error"
                     INITIALIZE IMAGE-HANDLE
               WHEN OTHER
                    DISPLAY MESSAGE BOX
                    "File successfully loaded"
                    TITLE "Success"
           END-EVALUATE.

ya the difference between WBITMAP-LOAD and WBITMAP-LOAD-PICTURE is one will give you an ACU Handle and the other will give you the IPictureDisp (windows) handle.

When you say you use the full path, do you mean:
COPY RESOURCE "C:\\myacuproject\\resource\\MyPic.bmp".
CALL "W$BITMAP" USING WBITMAP-LOAD, "C:\\myacuproject\\resource\\MyPic.bmp".


copy resource we don't use :)
only the call part with the full part like your sample.