|
|
 |
| Visual Basic 2008 Essentials If you are new to Visual Basic programming with version 2008, this is the place to start your questions. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Visual Basic 2008 Essentials section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

September 8th, 2009, 12:28 PM
|
|
Registered User
|
|
Join Date: Sep 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Painting and Graphics
Good Morning!
Maybe someone could help me out to understand Paint Events and drawing Graphics.
I have a main form with with an array of usercontrols on it; these Usercontrols are used so that graphics are drawn on each one independent of one another.
In the Main Form Load Event, I call a DrawMain subroutine which loops through each UserControl to perform graphic drawings. As the program loops through each UserControl, I call a subroutine called RefreshScreen which in turn calls the UserControl_Refresh method. This forces a UserControl_Paint event, which then draws my graphics accordingly. This occurs for each userControl until the loop is finished and proceeds.
I also use the Form_Paint Event where i call the DrawMain subroutine to update the screen display. After this initialization, I use a timer to refresh the screen display every 5 seconds.
I noticed that my Form_Paint event fires infinitely and never enters the TimerRefresh_Tick event that i use to refresh the screen. How come this would fire infinitely? What is the proper method for using the Paint Method to update graphics?
My thinking is this with the Order of Events:
Form_Load >>>> Calls Private Sub DrawMain
DrawMain >>>>> Calls UserControl Public Sub RefreshScreen
RefreshScreen >>>>>> Calls UserControl.Refresh Method
UserControl.Refresh >>>>> Forces UserControl_Paint Event
UserControl_Paint >>>>> Draws Graphics
Drawn Graphics >>>>> Forces Form_Paint Event to Trigger
Form_Paint >>>>> Calls Private Sub DrawMain
Thank you in advance for any thoughts on this topic!
Thanks,
Tuzz
|

October 23rd, 2009, 05:48 PM
|
|
Registered User
|
|
Join Date: Sep 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Discovered an answer, possibly!
After much heartache and toil, i discovered the following conclusion in regards to painting graphics in the paint event:
When painting graphics using the Paint Event for a control, a user must not modify any properties of that control that may trigger a paint event (i.e ForeColor, BackColor, etc....). Doing so will or may cause an infinite paint loop that never ceases. So, in other words, the Paint Event can only be used solely for graphics manipulation, control properties may not be modified while in the paint event.
I may be wrong on this, but as soon as i discovered this, I was able to get my program to work the way i wanted it.
Hope this sheds some light for other users, maybe this can help!
|

November 7th, 2009, 10:41 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2005
Location: , , .
Posts: 420
Thanks: 0
Thanked 14 Times in 14 Posts
|
|
Hi
You can try disabling the events before changing forecolor, backcolor etc
and then enable the event handler after the job is done
Cheers
Shasur
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Graphics |
scruffyduck |
BOOK: Visual Basic 2005 Programmer's Reference |
14 |
July 23rd, 2008 12:21 PM |
| c/c++ graphics |
hafizmuhammadmushtaq |
C++ Programming |
0 |
October 20th, 2007 12:33 AM |
| Help on graphics |
steparths |
C++ Programming |
0 |
June 30th, 2006 03:09 PM |
| graphics in C++ |
MASTER_1st |
C++ Programming |
2 |
November 28th, 2005 12:02 AM |
| Exception while painting properties window... |
KRYSTAAL |
BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 |
1 |
December 12th, 2003 10:29 PM |
|
 |