Hard Problems™ With Custom Controls

To flesh the idea out a bit more since you’re interested, you’d loop through the controls in the Window’s paint event and pass g through to each control. You’d give each canvas a method to call which would in turn call the canvas paint event. The individual controls won’t fire a paint event since you’re making them not visible. You could put one large canvas on the window and use its paint event, but that seems unnecessary.

You get the controls to use in layout mode, but all the drawing goes to a single graphics context.

Extrapolating one layer more, you could have all the drawing go to a Picture object, which then is drawn to the window.

I can see where you are going here, Tim, but I am concerned about performance. Some of my UIs are pretty busy with lots of controls, some of which need to be updated in as close to real-time as possible (imagine guages that report readings from medical devices connected to a patient - gotta update those things at least 10x/second).

I’ll probably ponder this whole thing overnight and see what pops into my head come morning.

Ultimately, I’m thinking of putting together a set of canvas-based replacements for common controls I need such as label, checkbox, etc. The more I think about it, though, the less flexible the whole thing becomes. I’d really like to be able to build it generically enough to make it useful to others (i.e., mimic the API for Label for my Label replacement, so you could drop in mine and your apps would still work, but without the issues I’ve run into with labels and have more features available.)

Certainly worth pondering.


This has been “Hard Problems™” with your host, Custom Controls. Tune in tomorrow for our next episode.

This program has been brought to you by the number 7 and the letter Q.

Have you thought about doing it all in the canvas?

[quote=76525:@Kimball Larsen]I’ve gotten some good progress on this, and have a solution that is working fine on the mac, but not on windows due to pretty horrible flicker. In my paint event for my canvas: (ignore magic numbers etc for positioning)

dim p as new Picture(g.width, g.height, 32) <CLIP> g.drawPicture(p, 0, 0)
Have you tried using p.DrawInto(g, x, y) instead of g.drawpicture?