New topic: drawing on window
<http://forums.realsoftware.com/viewtopic.php?t=45670> Page 1 of 1 [ 10 posts ] Previous topic | Next topic Author Message f_hendriksen Post subject: drawing on windowPosted: Mon Oct 22, 2012 6:40 am Joined: Fri Sep 18, 2009 8:09 am Posts: 57 I have 2 windows: window1 and window2 Window1 has a button with the following command: window2.graphics.ForeColor=&cff0000 window2.graphics.DrawRect(10,10,100,100) It doesn't draw anything on window2. What am i doing wrong? I know that I can use the paint event, but there are more buttons which do different drawing on window2. Top Bimal Post subject: Re: drawing on windowPosted: Mon Oct 22, 2012 6:54 am Joined: Mon Jan 16, 2012 8:08 am Posts: 134 Location: India Exactly what u r doing ................ What i am thinking that suppose if u click on the button of window1 and u want to saw the graphics of window2 then u have to write the code like this in the Action event of the Button Window2.Show() window2.graphics.ForeColor=&cff0000 window2.graphics.DrawRect(10,10,100,100) It might be ur solution if u want like this. If u have any problem let me know. Thanks Bimal Top f_hendriksen Post subject: Re: drawing on windowPosted: Mon Oct 22, 2012 7:32 am Joined: Fri Sep 18, 2009 8:09 am Posts: 57 The code doesn't work... there's no graphic Top DaveS Post subject: Re: drawing on windowPosted: Mon Oct 22, 2012 8:45 am Joined: Sun Aug 05, 2007 10:46 am Posts: 4194 Location: San Diego, CA You MUST do all drawing in the WINDOWS PAINT EVENT _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top f_hendriksen Post subject: Re: drawing on windowPosted: Mon Oct 22, 2012 9:54 am Joined: Fri Sep 18, 2009 8:09 am Posts: 57 That would mean I have several different paint events. How can i do that? Top DaveS Post subject: Re: drawing on windowPosted: Mon Oct 22, 2012 10:03 am Joined: Sun Aug 05, 2007 10:46 am Posts: 4194 Location: San Diego, CA No you have ONE paint event... you have no control over its existance... just what it does... I am confused as to why you think you need more than one? You have one window background, and one event to draw on it. In the PAINT event or Window2 put this g.ForeColor=&cff0000 g.DrawRect(10,10,100,100) If you want to push button1 and have picture 1, and button 2 and show picture 2... then have the ACTION event of each button create a PICTURE object (called myPicture for example)... draw on IT and in the PAINT event of the WINDOW put g.drawpicture myPicture,0,0 _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top neonash7777 Post subject: Re: drawing on windowPosted: Mon Oct 22, 2012 10:25 am Joined: Mon Nov 29, 2010 7:01 pm Posts: 287 f_hendriksen wrote:That would mean I have several different paint events. How can i do that? If you need several different paint events you simply condition out which paint event you need If case1 then //draw something elseif case2 then //draw something else end Keep in mind that if you teach your program how to draw something, say a button, you should have it in its own method so you can reuse it to draw it as many times as you want wherever you want. Top f_hendriksen Post subject: Re: drawing on windowPosted: Mon Oct 22, 2012 10:26 am Joined: Fri Sep 18, 2009 8:09 am Posts: 57 Thanks, I will try that Top f_hendriksen Post subject: Re: drawing on windowPosted: Mon Oct 22, 2012 11:57 am Joined: Fri Sep 18, 2009 8:09 am Posts: 57 i have one other problem: there are many (12) cases that have many colored circles. Is there a way to do this without too much code? Top kermit Post subject: Re: drawing on windowPosted: Mon Oct 22, 2012 12:31 pm Joined: Mon May 30, 2011 12:56 am Posts: 535 Quote:there are many (12) cases that have many colored circles. Is there a way to do this without too much code? Look into Object2D items and Group2D You can create circles of colors, and add then to a group, which is a property of the window. When the paint event fires, it gives you g, a graphics object. Use the Group2d to draw all the circles etc at once in the paint event. If the group contains items you do not want, destroy it and create a new one in a construction method. Then the next time Paint is called, it will draw the new group. Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 10 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
