Selfmade Web Icon Button with WebCanvas

hello, i need your help.
how can i access this icon in a web app?
i use a own class and set Super to WebCanvas, i will make a simple icon button.
at desktop it was easy because canvas have a backdrop property but this web canvas did not have this property so i need paint the button self.
screen 1
screen 2

Just drag the picture into the project.

i have the icons in a project folder contents /UI/Icons/ (screenshot 1)
i can’t drag them from there into a page (window)

You don’t drag it to the page, you drag it to the project (left hand side column of the IDE).

Then you draw it in the Paint event of the WebCanvas.

Emile Schwartz posted the code here https://forum.xojo.com/55693-add-icon-to-webpage

what is the correct place for resources if me will start it from ide in debug mode as standalone app?
if me put the icon beside the exe it get loaded once but after stop from ide the folder get clean up and next start its missing.
why is my project resource not copied into output folder at start?

i made a test project with paint into a webcanvas direct.

[code]Sub Paint(g as WebGraphics) Handles Paint

Dim Logo_FI As New FolderItem(“Ok.png”) <- incorrect use

If Logo_FI <> Nil And Logo_FI.Exists Then
Dim Logo_Pict As New WebPicture(Logo_FI)

g.DrawPicture(Logo_Pict,0,0)

Else
MsgBox “Image not found.”
End If

End Sub
[/code]

so it appear here at run :slight_smile:
msgbox SpecialFolder.Resources.NativePath
D:\MR_Xojo\DebugTestIconButton\DebugTestIconButton Resources\

this works now

[code]Dim Logo_FI As FolderItem = SpecialFolder.GetResource(“Ok.png”)

If Logo_FI <> Nil And Logo_FI.Exists Then
Dim Logo_Pict As New WebPicture(Logo_FI)

g.DrawPicture(Logo_Pict,0,0)

Else
MsgBox “Image not found.”
End If[/code]

…while running in the Xojo IDE. But a Web application is meant to run on a Web server: you made only a part of the job :frowning:

yes, i will copy it later to my vps but the resource sub folder would be the same. (i guess)

If you drag the picture into the project, it will automatically be placed in the Resources folder at compile time.

Drag it under “Contents” in the left hand side column, where all the elements of the program appear. It will then show as the name of the file without extension. In your example “OK”.

Then the content of Paint is simply:

g.DrawPicture(OK, 0,0,OK.Width, OK.Height)

I used OK.width and OK. Height, but you can also stretch or reduce the size with these two parameters.

[quote=452782:@Michel Bujardet]If you drag the picture into the project, it will automatically be placed in the Resources folder at compile time.

Drag it under “Contents” in the left hand side column, where all the elements of the program appear. It will then show as the name of the file without extension. In your example “OK”.

Then the content of Paint is simply:

g.DrawPicture(OK, 0,0,OK.Width, OK.Height)

I used OK.width and OK. Height, but you can also stretch or reduce the size with these two parameters.[/quote]

this syntax is much better, thanks for this hint.
now i know why it was “not” painted, lol, because i not used the images 2x 3x. o m g.

  • the transparent images 2x 3x was cached somewhere but now i can see my icon . yeah.