Desktop input fill, Backdrop tiling

Is there a way to fill a desktop input with color (or make it truly transparent) or create a border?
How do you tile a window background image?

I can do this on the web and I can put a canvas or something in back of some elements, but since inputs aren’t really transparent (on my WIndows 11 Surface laptop) a canvas won’t help there.

On the IDE, is there a way to adjust the grid (for example, make each grid 30 points)?

Thanks
fritz

In your Window paint event you could use the PictureBrush to accomplish this:

Var img As Picture = Picture.Open(SpecialFolder.Desktop.Child("Image.png"))
// Or if you already assigned a Backdrop to your Window
//img = Self.Backdrop

If img <> Nil Then
  Var b As New PictureBrush(img)
  b.Mode = PictureBrush.Modes.Tile
  
  g.Brush = b
  g.FillRectangle(0, 0, g.Width, g.Height)
End If
1 Like

William

When I use (in the Paint event of my desktop window)

Var b As New PictureBrush(img)

from your kindly provided code (with change of picture name and location) I get the error:

Window1.Paint, line 7
Too many arguments: got 1, expected only 0.
Var b As New PictureBrush(img)

Since it didn’t like the parameter, I guessed:

Var b As New PictureBrush
b.Image = cork
b.Mode = PictureBrush.Modes.Tile

and it worked fine.
(my background is named “cork” in the window backdrop property and “cork-board.png”)

Here is the code I ended up using:

Var img As Picture = Picture.Open(SpecialFolder.Documents.Child(“cork-board.png”))
// Or if you already assigned a Backdrop to your Window

img = self.Backdrop

If img <> Nil Then
'Var b As New PictureBrush(img)

Var b As New PictureBrush
b.Image = img
b.Mode = PictureBrush.Modes.Tile

g.Brush = b
g.FillRectangle(0, 0, g.Width, g.Height)
End If

I don’t know why I had to use both methods, the Picture.Open and self. Backdrop, but neither works by itself (for me).

You have solved my problem, but, if you have another minute, I’d love to know why one way worked and the other didn’t.

Thank you very much for your trouble.
fritz

1 Like

You’re probably using Xojo 2023r3 or older, since the new constructor that takes a Picture was added/available in 2023r4 or later.

Well that’s exactly right. I’m using 2023 r1.1.
Oh well.

Thank you,
fritz