Hi
I am using BB4W 6.15 on windows 11. I would like to display a gif file in my program. From the help topics I copied and pasted the PROC for displaying a gif
but when it runs I get message "not in a FN OR PROC" at line 2 . any help would be appreciated.
copy of code
Displaying GIF and JPEG images
The built-in *DISPLAY command will only display images in Windows Bitmap (.BMP) format. If you want to display images in GIF or JPEG (.JPG) formats you can do that using the following procedure (remember that you can copy and paste this code from the help window into your program):
DEF PROCdisplay(picture$,xpos%,ypos%,xsize%,ysize%)
LOCAL oleaut32%, olpp%, iid%, gpp%, hmw%, hmh%, picture%, res%
SYS "LoadLibrary", "OLEAUT32.DLL" TO oleaut32%
SYS "GetProcAddress", oleaut32%, "OleLoadPicturePath" TO olpp%
IF olpp%=0 ERROR 100, "Could not get address of OleLoadPicturePath"
DIM iid% LOCAL 15, picture% LOCAL 513
SYS "MultiByteToWideChar", 0, 0, picture$, -1, picture%, 256
iid%!0 = &7BF80980
iid%!4 = &101ABF32
iid%!8 = &AA00BB8B
iid%!12 = &AB0C3000
SYS olpp%, picture%, 0, 0, 0, iid%, ^gpp%
IF gpp% = 0 ERROR 100, "OleLoadPicturePath failed"
SYS !(!gpp%+24), gpp%, ^hmw% : REM. IPicture::get_Width
SYS !(!gpp%+28), gpp%, ^hmh% : REM. IPicture::get_Height
SYS !(!gpp%+32), gpp%, @memhdc%, xpos%, ypos%, xsize%, ysize%, 0, \
\ hmh%, hmw%, -hmh%, 0 TO res%
IF res% ERROR 100, "IPicture::Render failed"
SYS !(!gpp%+8), gpp% : REM. IPicture::Release
SYS "InvalidateRect", @hwnd%, 0, 0
SYS "UpdateWindow", @hwnd%
ENDPROC
This routine will also display Windows Bitmap (.BMP or .ICO) and Windows Metafile (.WMF or .EMF) images. Note that the required display position (xpos%, ypos%) must be specified in pixels, and is measured from the top-left corner of your program's output window to the top-left corner of the image. Note also that the file name must include the drive letter (e.g. C:) to distinguish it from a web URL, which can be used as an alternative means of specifying the image.
displaying a GIF
-
- Posts: 272
- Joined: Tue 18 Jun 2024, 09:32
Re: displaying a GIF
Most likely you're accidentally executing the procedure by 'falling into it' from the code above. Adding an END before the DEF PROC will stop that happening:
Code: Select all
END
DEF PROCdisplay(picture$,xpos%,ypos%,xsize%,ysize%)
-
- Posts: 2
- Joined: Thu 21 Nov 2024, 15:16
Re: displaying a GIF
Thank you Richard I will try that and download SDL 2.0
Regards
Regards
-
- Posts: 327
- Joined: Wed 04 Apr 2018, 06:36
Re: displaying a GIF
If you find that SDL doesn't quite meet your requirements and for some reason cannot get the other solutions to work, you can always use the IMGLIB library. Although it takes some getting used to - you need to set a DC handle before it will display anything - it is an excellent bit of code which allows you to easily rotate and zoom the picture as well as various other variations.
The major problem I found with it was using it in a multi-window environment, as you need a DC handle for each window but IMGLIB only allows one handle. If that is something you need, contact me privately and I'll be happy to share my solution with you.
The major problem I found with it was using it in a multi-window environment, as you need a DC handle for each window but IMGLIB only allows one handle. If that is something you need, contact me privately and I'll be happy to share my solution with you.