The program needs to regularly retrieve data from an activity table in the database, and display the list on the update interface. For example, if there are 20 data records (changed), the 20 Data
Constantly changing (implemented through other programs)
Solution (1): First search in the list, and then insert
For example, each record has a unique number. When querying, first check whether the number of records exists in the list.
After the item is found, the data of each column is directly updated, as shown in figure
Lvfindinfo lv;
LV. Flags = lvfi_string;
LV. psz = "keyword ";
Int nitem = m_list.finditem (& LV,-1 );
If item> 0, data is directly updated. Use setitemtext (nitem, 0, "value 1 "),....
If item <0, insert an item, insertitem (), and then setitemtext (nitem, 0, "");...
Solution 2:
Before each query, delete all the current records and insert them into the list box in sequence.
//////////////////////////////////////// //////////////////////////////////////// /// // Other methods
// Method 1: Disable repainting
Setwindowredraw (hwnd, false );
... Add the items...
Setwindowredraw (hwnd, true );
Method 2: Use the locking window to disable refresh.
M_list.lockwindowupdate ()
M_list.setitemtext ()
// After modification
M_list.unlockwindowupdate ()
Method 3: Use the virtual list technology.
Each time, data is first put into an array, and then updated based on the displayed amount. Lvn_getdispinfo message required
That is, (ongetdispinfolist (nmhdr * pnmhdr, lresult * presult) function,
Method 4: Use the memory buffer technology
The virtual table can solve the problem. If the data is still updated in a large amount of flashes, You need to modify the ondraw function. memdc can be used to implement the non-blinking solution.
Method 5: Reload the onerasebkgnd (CDC * PDC) Function
Reload the onerasebkgnd (CDC * PDC) function to make the customer area white in the background. If not, calculate the size of the data area when inserting data, if the data area covers the entire customer area, no background is set. In the past, we did not see flashes when we updated dozens of pieces of data in 1 s.