Real Software Forums
http://forums.realsoftware.com/

Making The Canvas A Global Entity
http://forums.realsoftware.com/viewtopic.php?f=13&t=45873
Page 1 of 1

Author:  RBnoob2012 [ Sun Nov 11, 2012 10:08 pm ]
Post subject:  Making The Canvas A Global Entity

Hi, me again ... still trying to shift my VB brain to RB.

In VB2010 if I put a PictureBox on Form1 I can manipulate it from Form2 even if Form2 is modal.

In RB I'm not able to manipulate Canvas1 on Form1 from another modal form.

Canvas1 is Public and I thought I understood that to mean its scope was outside its parent form.

What I'm trying to do is this:

I have Canvas1 on Form1. It sizes to the size of Form1.

As per my last post here, I learned to use DrawScreen to draw everything to a buffer and then use:
Canvas1.Refresh(False)
to fire the paint event which sets the buffer onto Canvas1. I got that working fine.

The problem is that unless I send Canvas1 as a parameter of my DrawScreen sub-routine, I cannot use Canvas1.Refresh(False).

Having to send Canvas1 as a parameter to DrawScreen prevents me from manipulating the screen from my modal Form2.

What am I missing that makes Canvas1 interactable from other Forms?

Thanks for your help,
RBnoob

Author:  timhare [ Sun Nov 11, 2012 10:46 pm ]
Post subject:  Re: Making The Canvas A Global Entity

Canvas1 exists on an instance of a window. You must use that instance variable name to access it.

Form1.Canvas1.Refresh(false)

- or -

dim w as new Form1
w.Canvas1.Refresh(false)

All depends on how you instantiate the window. The first example uses implicit instantiation. The second is explicit.

Author:  RBnoob2012 [ Sun Nov 11, 2012 11:14 pm ]
Post subject:  Re: Making The Canvas A Global Entity

ROFLMAO.

Oh my God, I can't believe how stupid I am. I just got done writing Form1.PictureBox1 in the VB2010 project to make sure I was right about being able to manipulate a the PicBox ... and it NEVER occurs to me that I'd have to do the same thing in RB.

Wow. Well, it's an indication of how much I've come to rely on all the little Intellisense-like aspects of VB2010.

Thanks for your help, timhare, I got it working ... and thanks for not laughing YOUR ass off at me!

Best Wishes,
RBnoob

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/