main page >programming tips (VB5/6) >  Refresh method for MDI forms     diese Seite auf deutsch diese Seite auf deutsch
 
For unknown reasons MDI forms do not have a Refresh method. However, it's easy to add this functionality. Insert the following into the code section of your MDI form:

Option Explicit
'API declarations
Private Declare Function UpdateWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function InvalidateAll Lib "user32" Alias "InvalidateRect" _
  (ByVal hwnd As Long, ByVal lpRect As Long, ByVal bErase As Long) As Long

'home-brewed Refresh method for MDI Forms
Public Sub Refresh()
InvalidateAll Me.hwnd, 0&, 1&
UpdateWindow Me.hwnd
End Sub
            


Update: As discussed under the topic "upgraded Refresh method" , this method may not work properly with Windows XP and later. So we best adopt the solution provided with this article:

Option Explicit

'home-brewed Refresh method for MDI Forms
Public Sub Refresh()
RefreshEx Me.hwnd
End Sub
            
main page >  programming tips (VB5/6) >  this page