• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 175
  • Last Modified:

Drawing on a form, a few questions


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
1 Solution
1) Set AutoRefresh to TRUE.

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


oregAuthor Commented:


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.

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.
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));

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now