Article Preview
Buy Now
FEATURE
Windows Fast Listbox Updating
How to quickly update a Windows listbox without flickering
Issue: 15.4 (July/August 2017)
Author: Eugene Dakin
Author Bio: Eugene works as a Senior Oilfield Technical Specialist. He has university degrees in the disciplines of Engineering, Chemistry, Biology, Business, and a Ph.D. in Chemical Engineering. He is the author of dozens of books on Xojo available on the xdevlibrary.com website.
Article Description: No description available.
Article Length (in bytes): 7,426
Starting Page Number: 21
Article Number: 15404
Resource File(s):
project15404.zip Updated: 2017-07-02 23:29:47
Related Link(s): None
Excerpt of article text...
This article shows how to quickly update a listbox control by minimizing the flickering that happens on Windows by using a Windows Declare subroutine.
Although this example is specific to the listbox control, any of the controls, or the entire window, can be updated in a similar manner with the
WM_REDRAW
message. TheWM_SETREDRAW
constant works with SendMessage to update either individual controls, or the entire window with all controls. When only one control is to be updated, there is no need to update, resize, repopulate, and redraw code for existing controls that have not changed. Its easier and more efficient for the program and Operating System to only update the one control, which minimizes flickering. The other benefit is that the control is updated with a thousand pieces of data and is redrawn only once, which also further reduces flickering of the control.One word of caution, every time there is a call to the listbox when the wParam value is one, whether it is to add a new row or call refresh, then the listbox will be redrawn. To be as efficient-as-possible, it is good practice to perform as many updates as possible with the wParam value set to 0 (False) and update the control only once.
Each message to the window has a constant and the
WM_SETREDRAW
has a constant hexadecimal value of B which is written as &HB.Figure 1 is a screen grab of the running program with a listbox that has been updated.
To create this example, drag-and-drop a listbox control onto
window1
and add apushbutton
control with anaction
event. Here is the working code:
...End of Excerpt. Please purchase the magazine to read the full article.