scolling canvases on canvase - windows

Hi there. I have a canvas. On top of the canvas i have run-time generated other canvases (a control array)…
The idea is that I can click on the canvases which will do a method to draw graphics into the picture that fit inside the square of the new canvas.
I’ve got the example based scrolling going on. This is working well in regards to the actual picture.

in the paint of this canvas I have:
g.DrawPicture(ChordDiagram,0,0-YScroll)

However, I can seem to get the new canvases to scroll relative to the picture. They go out of skew. I’ve tried all sorts of workarounds.

For fun I chucked a button onto the canvas… it scrolled just fine (relative to the picture.)
Canvases are controls as well - shouldn’t they scroll as well as the button?
What am I missing?
Cheers

[quote=217796:@Sean Clancy]Hi there. I have a canvas. On top of the canvas i have run-time generated other canvases (a control array)…
The idea is that I can click on the canvases which will do a method to draw graphics into the picture that fit inside the square of the new canvas.
I’ve got the example based scrolling going on. This is working well in regards to the actual picture.

in the paint of this canvas I have:
g.DrawPicture(ChordDiagram,0,0-YScroll)

However, I can seem to get the new canvases to scroll relative to the picture. They go out of skew. I’ve tried all sorts of workarounds.

For fun I chucked a button onto the canvas… it scrolled just fine (relative to the picture.)
Canvases are controls as well - shouldn’t they scroll as well as the button?
What am I missing?
Cheers[/quote]

Have you made sure to set the scrolling canvas as parent of the one you dynamically added ?

thatCanvas.Parent = ScrollingCanvas

I think helped a lot. Now… the probem now is that the actual canvases which I click on are not moving up with the picture… Should I move the canvas.tops up? My picture is right at the top of the window…
I did set the parent of the runtime canvases to my main canvas.

[quote=217819:@Sean Clancy]I think helped a lot. Now… the probem now is that the actual canvases which I click on are not moving up with the picture… Should I move the canvas.tops up? My picture is right at the top of the window…
I did set the parent of the runtime canvases to my main canvas.[/quote]

This is becoming confuse. Canvas over canvas. Which one and what is it supposed to do ?

Are you actually embedding the canvases in the ScrollingCanvas (so they become part of it) or just layering them on top (in which case the scrolling has no effect on them)?

Look for embedWithin …

Also look at ContainerControls as the technique is well described there. Read Bob’s blog post

http://www.bkeeneybriefs.com/2014/02/container-control-love/

Paul has a webinar which might be helpful.

http://www.youtube.com/watch?v=wMhaX0ZCK5A

Ignore what I wrote. Can’t delete it for some reason.

[quote=217796:@Sean Clancy]Hi there. I have a canvas. On top of the canvas i have run-time generated other canvases (a control array)…
The idea is that I can click on the canvases which will do a method to draw graphics into the picture that fit inside the square of the new canvas.
I’ve got the example based scrolling going on. This is working well in regards to the actual picture.

in the paint of this canvas I have:
g.DrawPicture(ChordDiagram,0,0-YScroll)

However, I can seem to get the new canvases to scroll relative to the picture. They go out of skew. I’ve tried all sorts of workarounds.

For fun I chucked a button onto the canvas… it scrolled just fine (relative to the picture.)
Canvases are controls as well - shouldn’t they scroll as well as the button?
What am I missing?
Cheers[/quote]
Make sure the subcanvases are completely within the bounds of the outer one. You might also want to consider just using the Graphics.Clip in the paint event of the outer canvas and do away with all of the subcanvases.

First of all, I’m am doing it in Windows (If I can get it to work in windows, then it will certainly work on mac)

I have this as a method:

LockWindow(hw as integer) #if TargetWin32 Then Declare Sub LockWindowUpdate Lib "user32" (ByVal hWnd As Integer) LockWindowUpdate hw #endif

I have this in the main canvas paint event

g.DrawPicture(ChordDiagram,0,0-YScroll)

The big problem is this…
I have controls on the scrolling canvas. When I click on these controls, I have a method called “Drawneck” which
sets g=chorddiagram.graphics
In this method it draws a rectangle around the control. When the picture is not scrolled, it works perfectly. Once the rectangle is drawn, I can press another button (not on the canvas) to draw onto chord diagram the value.

The problem is when it’s scrolled. (yscroll is changed by a vertical scroll bar)
methods which go to draw onto “ChordDiagram” Draw them not around the controls but higher on chorddiagram.
Any recommendations?

Without code, the explanation is not very clear.

I am assuming

  • this is a guitar neck
  • the canvas over the top is meant to add the finger positions
  • the canvas over the top is mostly transparent
  • the main canvas scrolls to show another part of the neck

Either your overlaid canvas is showing all 6 finger positions at once, or you have 6 canvas objects, one for each finger.

If the neck image is not drawn ‘correctly’, (and all spaces between frets are shown to be the same width), then the overlaid canvas for a G shape could be placed anywhere on the neck and still look OK.
If so, the overlaid canvas can stay put, leaving the neck image to move behind it in steps of exactly one fret
(If the neck is drawn correctly, then the gaps between fingers is greater closer to the nut)

If the overlaid images are of the individual fingers, why use extra canvases at all, as Greg suggests?
Just add the finger images in the Paint event.

(ie, in the paint event, draw the image of the neck.
Then draw circles for the fingers at the correct positions on top of it)

If the neck image is set to be the main canvas backdrop, then only draw the finger placings in the paint event.