Solved

STOPPING Automatic VISUAL UPDATE of ListBox by Windows?

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sending a email via excel using vba 6 119
Microsoft Access combo box help 2 57
Excel VBA, find a string in a column, update a cell 7 117
clicking a shape in a frame array vb6 3 55
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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

751 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