Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lines drawn at runtime disapear

Status
Not open for further replies.

simonkue

MIS
Jul 9, 2002
105
GB
Still cannot search, so don't know if this has already been answered....

When I draw a line on a form at run time, then place another window on top of this form (eg Word, or Explorer) by using Alt-Tab (ie nothing to do with this app), the lines beneath the new window are removed. All design time controls are left on the form.

I have tried this with lines directly on the form and via a picture box and get the same result.

It's as if the form is re-drawn when it becomes active again, rather than staying in the state I left it with the extra lines.

Does anyone know how/why this happens and whether there is something I'm not doing or there is a workaround. I need to construct an image at run-time comprising a number of lines that can be displayed on a form - ideally via VB?

Thanks in anticipation.
 
There are two solutions for this problem:

1:
Set the AutoRedraw property of your form to True
This has a slight impact on performance, since the runtime needs to update your form as well as an in-memory image.

2:
Draw your lines (and everything else you put on your form at runtime, like text) in the OnPaint event.
Greetings,
Rick
 
Hi,

Set the autodraw property of the form to true. Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Sunaj & Lazyme,

Thanks for this. I just discovered this as I was going through the form properties, changing them to see what happens. This was a last resort having spent all day working through manuals and MSDN for clues and finding none.

By the way Sunaj, your signature quote is great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top