Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleRedraw a form once when it has finished resizing
Keywordsresize, finished, done
CategoriesTips and Tricks, API
 
Normally a form receives the Resize event many times while you resize it. Redrawing a complex picture each time can cause flickering.

What you really need is a ResizeFinished event. Unfortunately there is no such thing in VB.

The solution is to subclass the form and watch for the WM_EXITSIZEMOVE message. When you see it, the resizing is finished.

 
' Watch for the WM_EXITSIZEMOVE event.
Public Function NewWindowProc(ByVal hwnd As Long, ByVal msg _
    As Long, ByVal wParam As Long, ByVal lParam As Long) As _
    Long
Const WM_NCDESTROY = &H82
Const WM_EXITSIZEMOVE = &H232&

    ' If we're being destroyed,
    ' restore the original WindowProc.
    If msg = WM_NCDESTROY Then
        SetWindowLong _
            hwnd, GWL_WNDPROC, _
            OldWindowProc
    End If

    ' Redraw the form.
    If msg = WM_EXITSIZEMOVE Then Form1.DrawForm

    NewWindowProc = CallWindowProc( _
        OldWindowProc, hwnd, msg, wParam, _
        lParam)
End Function
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated