Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 14 in printed book and digital formats -- plus a one-year subscription so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 15.4 ('Xojo in Germany')
Instant purchase and download via GumRoad!

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):

Download Icon 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. The WM_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 a pushbutton control with an action event. Here is the working code:

...End of Excerpt. Please purchase the magazine to read the full article.