On 10/06/06, Björn Eiríksson <[EMAIL PROTECTED]> wrote:
On 10.6.2006, at 01:39, Ed Lee wrote: > Folks: > > I'm trying to use a graphics object with a canvas, and it's causing > my app to crash without any explanation. > > Try this: > > 1. Create a new project. In Window1, add a canvas (Canvas1). > 2. In the code for Window1, add a property tempGraphic As Graphic. > 3. In the code for the Open event handler, add the following: > > tempGraphic = new Graphics > tempGraphic.DrawRect(1,1,20,40) > > 4. In the code for Canvas1.Paint, add one line: > > g = tempGraphic You cannot create instance of Graphics, to create off screen buffer then you create a instance of a picture and the get the Graphics from the Picture.
Wich means: Add a property "Buffer as Picture" to you window. In the open event (of the window) put this: "Buffer=new Picture(Canvas1.Width,Canvas1.Height,32)" and in the Paint event (of the Canvas) put this: g.DrawPicture Buffer,0,0 If you are working on windows and you are using the canvas intensivly, it will flicker. You can solve that with a little work. Set Canvas1.EraseBackground to False. Dont draw to the canvas, but to Buffer. When you are done drawing, call Canvas1.Refresh(False). However, this way, you're canvas won't be transparant. It will always have a background. _______________________________________________ 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>
