Solved

LockWindowUpdate

Posted on 2002-04-09
5
757 Views
Last Modified: 2010-05-18
Hi,

I'm updating a ListView which contains about 150 items.  The update requires me to completely repopulate the entire ListView.  The problem is, it takes ages and looks disgusting when the items are deleted and re-added.  I've played around with LockWindowUpdate, and that works fine with the ListView, but my desktop refreshes when I release the lock.

Here's my code:

begin
  LockWindowUpdate(DataListView.Handle);
  {code}
  LockWindowUpdate(0);
end;

Is this correct?  If so, why does the desktop refresh?

This has happened to me on 98SE, 2000 and XP.  I haven't tried it on any other versions of Windows.

Cheers,

Stu
0
Comment
Question by:Stuart_Johnson
[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
  • 2
5 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
ID: 6930447
why not use

begin
  DataListView.Items.BeginUpdate;
  try
    {code}
  finally
    DataListView.Items.EndUpdate;
  end;
end;
0
 
LVL 17

Expert Comment

by:inthe
ID: 6930530
hi stu,
this is a "bug" since d2 ,seems to be with most delphi twincontrols ,you can do as meikl suggested or put a panel under the listview and call lockcontrol on the panel
(suggested by TeamB) :

procedure LockControl(c: TWinControl; lock: boolean);
  begin
    if (c=nil) or (c.Handle=0) then exit;
    if lock then SendMessage(c.Handle,WM_SETREDRAW,0,0)
    else begin
      SendMessage(c.Handle,WM_SETREDRAW,1,0);
      RedrawWindow(c.Handle,nil,0,RDW_ERASE or RDW_FRAME or RDW_INVALIDATE or RDW_ALLCHILDREN);
    end;
  end;


LockControl(panel1,true);
//do stuff
LockControl(panel1,false);
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 6930572
Hi Barry,

LOL!  3 versions later and it's still not working.  Let me guess, it's knackered in v6 as well?

Thanks for the code.  Which one would either/both of you suggest I use?  Meikl's suggestion works fine, but if yours is the more "accepted" way of doing it, then I'd prefer to go that way.

Cheers,

Stu
0
 
LVL 17

Expert Comment

by:inthe
ID: 6930597
yeh it must be something quite deep in the source tree otherwise it would be fixed ,the earliest mention of the problem i found was 1996!

anyway, i would use beginupdate/endupdate.
lockwindowupdate or lockcontrol is a bit of an overkill really for this ;-).

Regards Barry
0
 
LVL 6

Author Comment

by:Stuart_Johnson
ID: 6930949
No worries, Barry.  However, I'll put that code into CodeBank for later use :)

Thanks for the help, Meikl.  It worked well.

Stu
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month9 days, 4 hours left to enroll

615 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