Link to home
Start Free TrialLog in
Avatar of ExDev001
ExDev001Flag for Italy

asked on

How to know LockWindowUpdate state for a specified control

Hello,
I'm using Windows.LockWindowUpdate in order to optimize control's drawing while moving and resizing.
Something like this:
LockWindowUpdate(MyPanel.Handle);
//some code here
//...
//...
LockWindowUpdate(0);

Open in new window


Sometimes I need to know if LockWindowUpdate is enabled or disabled for a specified control.
Something like "IsWindowUpdateLocked()".
How can this be done? (If it can be done..)
Thanks for your willingness.
Avatar of akb
akb
Flag of Australia image

The only way I can think to do it is to define a Boolean flag to go with each control you want to know the status of and set it to true or false as you set lockwindowupdate on or off.
Avatar of Sinisa Vuk
According to this: http://msdn.microsoft.com/en-us/library/windows/desktop/dd145034%28v=vs.85%29.aspx
A locked window cannot be moved
Try to use Panel.DoubleBuffered:=True or Form.DoubleBuffered:=True.
Avatar of ExDev001

ASKER

Isn't there another way?
ASKER CERTIFIED SOLUTION
Avatar of Sinisa Vuk
Sinisa Vuk
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello, your informations helped me in writing IsWindowUpdateLocked function.

function IsWindowUpdateLocked() : boolean;
begin
  Result := not LockWindowUpdate(Application.Handle);
  if(not Result)
  then LockWindowUpdate(0);
end;

Consider that LockWindowUpdate fails if another window is update-locked.
Furthermore, LockWindowUpdate doesn't causes auto-update.