Solved

STOPPING Automatic VISUAL UPDATE of ListBox by Windows?

Posted on 1998-11-26
2
143 Views
Last Modified: 2010-05-03
Is there a way to stop that visual update that windows does to a listbox control when ie. you set an item in the box to be checked with a listbox1.Selected(0) = true? Everytime i call the select function to have an item selected it ALWAYS shows it checking onscreen. This is completely fine, however, when i have to select 2000 items that reside in the box seeing each one checked on takes MUCH LONGER than if it were to do it in the background (non-visible) and then have it display the final list all checked in one update.
I am sure most of you will say "just have another ListBox with the same content, make it invisible, and have all the items checked on and once it is done just set the original to invisble and the new to visible". I can do this but i don't want to be so wasteful with memory. Is there a function in vb to tell a control to not have its visually changed contents displayed until i want it to?

Thanks
0
Comment
Question by:aniston
2 Comments
 
LVL 14

Accepted Solution

by:
waty earned 10 total points
ID: 1446882
Use the following function :

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
 

Author Comment

by:aniston
ID: 1446883
You are a ****ing lifesaver!! Thanks very much for such a BRILLIANT ANSWER
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

830 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