Use HTML viewer to load an image.

I must be overlooking something simple again, because I’ve tried everything I can think of with no luck.

How do you load a compatible image into the HTMLviewer?

I have the image in my project. I’m trying to load it at launch.

dim f as Picture

f = LOTR

htmlviewer1.LoadPage (f)

I’ve tried a hundred other combinations…no luck

“picture” is not compatible with HTMLViewer…

What is compatible is a string containing valid HTML code.

If you purpose is to display a picture to the user on app launch… why not use the paint event of a canvas instead of using HTMLViewer

It’s an animated GIF. I know it can be done…I’ve done it before…just forgot what I did.

You’ve got to wrap it in html.

I don’t think so. I did it back in 2011 when I first started using Real Studio…

Besides, you can drop it right in the window and it works…so no wrapping in html…

Have you tried

 HTMLViewer1.LoadURL("file:///PATH TO FILE")

You could load it in the app contents in a copy files step then reference its path to open it that way.

I’m a little fuzzy on that. The gif is already in the project. How do you point it at itself?

Create a copy files step for the .gif and specify its placement into the Resources folder. Then you can access it like this in an HTMLviewer:

dim f As FolderItem = app.ExecutableFile.Parent.Parent.Child("Resources").Child("FILE NAME.gif") dim s as string = ReplaceAll(f.NativePath, " ", "%20") HTMLViewer1.LoadURL("file://"+s)
This is what I use on my Mac, if you are doing windows the path to the file might have to be changed.

Cool! That works great on a Mac. Now I need to get it working on Windows. I’m familiar with the internal package structure of a Mac App Bundle, but not the path of an EXE.

Any one know?

dim f As FolderItem #if TargetMacOS f = app.ExecutableFile.Parent.Parent.Child("Resources").Child("FILE NAME.gif") #else f = app.ExecutableFile.Parent.Child("Resources").Child("FILE NAME.gif") #endif dim s as string = ReplaceAll(f.NativePath, " ", "%20") HTMLViewer1.LoadURL("file://"+s)

[quote=59848:@shao sean] dim f As FolderItem #if TargetMacOS f = app.ExecutableFile.Parent.Parent.Child("Resources").Child("FILE NAME.gif") #else f = app.ExecutableFile.Parent.Child("Resources").Child("FILE NAME.gif") #endif dim s as string = ReplaceAll(f.NativePath, " ", "%20") HTMLViewer1.LoadURL("file://"+s) [/quote]

I get an exception of class nilobjectexception on Windows when I use that code.

You need to copy the file next to your executable.

Eh, that’s really ugly. If you can embed pics into the image well, you should be able to embed pics into the html viewer.

Even if I copy the pic using that path provided, (and not even trying to load it in html viewer) I still get the same error on Windows. I think the path shao sean provided isn’t correct for a Windows exe.

Anyone know?

The path for the Windows app is :

 f = app.ExecutableFile.Parent.Child("FILENAME.gif")

Just copy FILENAME.gif in the same directory as your application exe.

Copyright a file into the executable Folder isn’t a option. This might work o. your developer PC but Most Users don’t work as privileged or admin users. On both Mac and Windows you cannot put anything into your app folder anymore. Use Users or system temp Folder instead.

[quote=59935:@Michel Bujardet]The path for the Windows app is :

 f = app.ExecutableFile.Parent.Child("FILENAME.gif")

Just copy FILENAME.gif in the same directory as your application exe.[/quote]

Well, no error anymore, but no file either. This code works perfectly on Mac OS X, but copies no file on Windows.

[code] dim f As FolderItem
#if TargetMacOS
f = app.ExecutableFile.Parent.Parent.Child(“Resources”).Child(“Ladies.gif”)
#else
f = app.ExecutableFile.Parent.Child(“Ladies.gif”)
#endif

dim dir as FolderItem
dir = SpecialFolder.desktop
f.copyfileto (dir)[/code]

On Windows, you can install all files you want together with the exe when you install the app. Don’t confuse with Mac.

The code does not copy the file. It just opens it. You must place the file yourself in the install folder.

For debug purposes, you can use a copyfile, but for the release, you will have to copy the file with an installer.

Well that sucks. Why can’t you install a file from the exe? All kinds of development tools support this, WiseScript, AutoIT, etc…

I thought that’s what we’re were talking about. Why else would you use the path you supplied? It’s pointed internally.