Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Drawing on a form, a few questions

Posted on 1999-07-23
Medium Priority
Last Modified: 2010-04-30


I have a few questions about drawing on a window (form) using things like .line .circle etc....

1 - Is there anyway to get my lines, circles to show up on screen WITHOUT calling the .refresh function?  Also on this line of though, anyway to STOP it from erasing the window when it updates, and only adding in the new lines I drew?

2 - How would I update ONLY a small portion of the screen ( clipping or something like that I think it is called ), when I call refresh, or some other function.  Basically I need to update approx 100x100 pixels around the cursor, but right now when I call .refresh on the form, it updates the entire window, and this leads to massive flicker ( and CPU usage I would imagine ).

Thanks for any help
Question by:oreg
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 12

Expert Comment

ID: 1526919
1) Set AutoRefresh to TRUE.

2) It doesn't know how to only redraw a portion of the image.



Author Comment

ID: 1526920


Thanks for the first question, but the second is the really important one, I need to know how to update a portion of the screen, the flickering is way too much.


Expert Comment

ID: 1526921
Try placing all of the code for drawing your lines, circles, etc. in the form_paint event.

In other words, get all your data set whereever you need to, using public variables as needed. Then place the code needed to actually draw your graphics in the paint event, using that data. You can use arrays for drawing variable numbers of lines, etc.

Then, when you have finished building your data to draw the graphics objects, do a form1.refresh, which will fire the paint event, which should make your display update smoothly.

Accepted Solution

AnswerTheMan earned 300 total points
ID: 1526922
This API32 function will update only part of the window :
Public Declare Function InvalidateRect Lib "user32" Alias "InvalidateRect" (ByVal hwnd As Long, lpRect As RECT, ByVal bErase As Long) As Long
u should supply the hwnd(you have this property), the Rectangle you want to be refreshed, and the bErase which is
really a Boolean (1 or 0));


Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question