Custom Control Preview Picture

hello,
if me add a class and set super to canvas and use this in a window as control.
how can i have a preview picture in the ui designer, instead of all look like a rectangle.

[quote=468985:@Markus Rauch]hello,
if me add a class and set super to canvas and use this in a window as control.
how can i have a preview picture in the ui designer, instead of all look like a rectangle.[/quote]

Quick & Dirty (but never tested by myself): You could create a Preview manually and add the Picture to your Project. Then set it as the Background in the IDE. In the Open Event, you can set the Background Picture back to NIL.

Good Idea, Thanks

in xojo IDE it will always look like a rectangle. to have your picture, you must compile an external plugin

I use the method that Sascha does…
or if my control has a LABEL in it… I put identifiing text as the default value of that label, and removed in during OPEN

plugins can do custom drawing because their code is actually loaded byt the IDE & can be executed
they are fully compiled dynamic libraries

canvas based custom controls do not execute their paint event as your paint event is JUST “text” until such time the IDE compiles & runs the code

I read those lines, but I didn’t get it what I need exactly to do. I’ve created a Subclass of Canvas with the following Code in the Canvas.Open-Event:

[code]Var p As Picture = TrueWindow.BitmapForCaching(100, 100)
Var g As Graphics = p.Graphics

g.DrawingColor = Color.White
g.FillRectangle(0, 0, g.Width, g.Height)

Self.Backdrop = p[/code]
If I now place the Canvas on a Window, no “preview” will shown. Could you please provide an example project?

You cant do anything that requires code as it wont be executed in the IDE
Basically if your control is a subclass of canvas the best you can do is add a picture to your project
Then set instances of your control to have that picture as their backdrop
But you need to add 2 items to your project - your subclass AND the picture