Solved

STOPPING Automatic VISUAL UPDATE of ListBox by Windows?

Posted on 1998-11-26
2
140 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now