?
Solved

Flicker free form resize

Posted on 1998-10-24
8
Medium Priority
?
447 Views
Last Modified: 2012-08-13
I have a form and a few controls(a ListView, 3 command buttons,an activex control(mine) and an ImageList)

When the form is resized, I have a module that resizes all controls on the form, proportionately (I mean they are resized the same percentage as the form)

My problem that hwen the form is resized it causes a lot of flickering.  Does anyone have a remedy to this or has any pointers to sources.

Thank you all  
0
Comment
Question by:gbzhhu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 9

Expert Comment

by:david_levine
ID: 1441395
Here are some suggestions I found when searching the net:

The reason it might be flickering is because you are doing lengthy operation that have to do with the window every time it resizes. To minimize flickering in such situations insert the LockWindowUpdate function in the beggining of the resize event passing the hwnd of the form and putting the lockWindowupdate at the end with a 0 as its parameter. The LockWindowUpdate can be found in your API Viewer that came with Visual Basic.

-----------------------------------------------------

You might want to try looking at the LockWindowUpdate API ... pass it the hwnd of the window you want to freeze, and then pass a 0 in to unlock the update. Eg.,
Public Declare Function LockWindowUpdate Lib "user32" Alias _
"LockWindowUpdate" (ByVal hwndLock As Long) As Long

LockWindowUpdate Form1.Hwnd
 ' do stuff
LockWindowUpdate 0

Depending on what you are doing, it may help. If your code takes a second or two while the screen is frozen, you probably should change the mousepointer as well so the user doesn't think it's locked.
Sometimes it may also be worth it to subclass the form and get the messages so you can discard some redraws in case they are unnecessary.



0
 
LVL 12

Author Comment

by:gbzhhu
ID: 1441396
I am still getting flickering and decided that the module was doing too much calculation and redrawing and if I minimize the form the program crashes with a message out of memory

If you or anyone has code that can resize the controls on the form I would appreciate it

Thanks
 
0
 
LVL 14

Expert Comment

by:waty
ID: 1441397
I use this function in all my applications. It greatly speed up.
Add this function and encapsulate your work like this.

   SetRedraw Me, False
   ' *** Do work
   SetRedraw Me, True

' *** Preserve the refresh of a window
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long

Public Sub SetRedraw(frm As Form, bRedraw As Boolean)
   ' #VBIDEUtils#************************************************************
   ' * Programmer Name  : Waty Thierry
   ' * Web Site         : www.geocities.com/ResearchTriangle/6311/
   ' * E-Mail           : waty.thierry@usa.net
   ' * Date             : 19/11/98
   ' * Time             : 16:43
   ' * Module Name      : Lib_Module
   ' * Module Filename  : Lib.bas
   ' * Procedure Name   : SetRedraw
   ' * Parameters       :
   ' *                    frm As Form
   ' *                    bRedraw As Boolean
   ' **********************************************************************
   ' * Comments         : Enabled/Disable Window redraw
   ' *
   ' *
   ' **********************************************************************

   If (bRedraw = True) Then
      LockWindowUpdate 0
      frm.Refresh
   Else
      LockWindowUpdate frm.hWnd
   End If

End Sub

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Author Comment

by:gbzhhu
ID: 1441398
Waty your solution uses the same API as David Lavine and it does not solve my problem.  

Thanks
0
 
LVL 14

Expert Comment

by:waty
ID: 1441399
Add the call in the form_Resize
0
 
LVL 12

Author Comment

by:gbzhhu
ID: 1441400
Waty your answer works how can I give you the points

thanks
0
 
LVL 14

Accepted Solution

by:
waty earned 200 total points
ID: 1441401
Responde to this.
0
 
LVL 12

Author Comment

by:gbzhhu
ID: 1441402
Thanks waty
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month14 days, 2 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question