F.A.Q. - When I unload a shaped form it leaves an 'imprint' on the background behind it until a window is moved over and off it. How do I make it refresh automatically on unloading?

I don't know why some users have complained of this problem. I can not reproduce it myself, however I can produce code which will refresh the screen when the form unloads, which should solve the problem.

Put this code in the (general) section of the form:

Private Declare Function RedrawWindow Lib "user32" (ByVal hwnd As Long, lprcUpdate As RECT,ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As Long

Private Declare Function GetDesktopWindow Lib "user32" () As Long

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private Const RDW_INVALIDATE = &H1
Private Const RDW_ALLCHILDREN = &H80
Private Const RDW_UPDATENOW = &H100

Private Declare Function GetWindowRect Lib "user32" Alias "GetWindowRect" (ByVal hWnd As Long, lpRect As RECT) As Long

Private RedrawArea As RECT

Then in the form_unload event use:

GetWindowRect frmAbout.hWnd, RedrawArea '(Leave this line out to redraw the entire screen)

'<You might need these two, or not. I don't know. Try it without, it might work. If not, put them in...
frmAbout.Visible = False
DoEvents
'>

RedrawWindow GetDesktopWindow, RedrawArea, 0, RDW_INVALIDATE Or RDW_ALLCHILDREN Or RDW_UPDATENOW


Navigation: Index FAQ Index