Nice interface. One way to do it is the following. Rewrite all of your controls as classes that do not inherit from RectControl. Add Top, Left, Width, Height, Enabled, Visible, etc. properties to each. Then add some methods.

Sub Draw(g as Graphics)

This method draws the control into g, using its coordinate properties and state information.

The other big task you'll need to handle is mouse events. Probably the way to do it is to add methods HandleMouseDown(X as Integer, Y as Integer) as Boolean, HandleMouseDrag(X as Integer, Y as Integer) and HandleMouseUp(X as Integer, Y as Integer). In these methods you would set the draw state, call Action events, etc.

Given a mouse event on the Canvas, finding the appropriate control to handle it will be an interesting problem, though one that has obviously been solved before. The search should occur in the course of handling MouseDown; once that occurs, MouseDrag and MouseUp are handled by the same control. The simplest thing to do would be to search through the list of control objects until you find the one in which the control lies. A more complicated thing to do would be to keep a list of controls sorted first by top, then by left. Then you could do a binary search.

Charles Yeomans


On Feb 13, 2006, at 12:16 PM, Dave Addey wrote:

Hi Joe,

Thanks for the tip. Unfortunately, I don't know how else to achieve the
interface I have:

http://www.dj1800.com/images/fullscreen.gif

Each of the control elements (knobs, sliders etc.) is a canvas (actually a
custom subclass of a canvas). Each of the four wide rack devices is a
canvas, with the control elements on top of it. The entire window has a background canvas, which is used to scroll the rack devices when the window
is smaller than the combined height of the four rack devices.

Using canvases as the control elements provides an excellent way for me to
deal with the controls as objects and subclasses.

How should I best achieve all of this without using the layered canvases?

Dave.

From: "Joseph J. Strout" <[EMAIL PROTECTED]>
Reply-To: REALbasic NUG <[email protected]>
Date: Mon, 13 Feb 2006 10:00:32 -0700
To: REALbasic NUG <[email protected]>
Subject: Re: Double-buffered windows on Windows

At 4:51 PM +0000 2/13/06, Dave Addey wrote:

I'm being very careful to double-buffer the individual controls when drawing control changes to them. But the problem is the redraw of the window - each control redraws (without flicker) in turn, but because some canvas controls are on top of others, the combined redraw is very obviously layered and
looks flickery all the same.

The only way to avoid that is to stop layering canvases on top of
each other.  Since a canvas is nothing but a rectangular portion of a
window in which you can draw, there is very rarely any need to
overlap them.

Best,
- Joe

--

Joseph J. Strout
[EMAIL PROTECTED]
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


--------------
Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to