Link to home
Start Free TrialLog in
Avatar of faustomen
faustomen

asked on

Blinking item in TListView

How may I blink a specific item in TListView?

ASKER CERTIFIED SOLUTION
Avatar of Colin_Dawson
Colin_Dawson

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
Avatar of Russell Libby

Something like the following will allow you to "blink" (it inverts the image)  the list item without having to use a timer, and without having to implement owner-drawing. May make things a little easier to implement....

Regards,
Russell

procedure BlinkListItem(Item: TListItem);
var  hdcPaint:      HDC;
      rcBounds:      TRect;
begin

  // Check assignment
  if Assigned(Item) then
  begin
     // Get the bounds rect for the item
     rcBounds:=Item.DisplayRect(drBounds);
     // Get the window DC
     hdcPaint:=GetDC(Item.Handle);
     // Invert the item
     Assert(InvertRect(hdcPaint, rcBounds), 'Failed to invert the rectangle');
     // Release the dc
     ReleaseDC(Item.Handle, hdcPaint);
     // Validate the item rectangle
     ValidateRect(Item.Handle, @rcBounds);
     // Delay
     Sleep(500);
     // Have the item repaint
     InvalidateRect(Item.Handle, @rcBounds, True);
  end;

end;

Avatar of Colin_Dawson
Colin_Dawson

I'm glad that I gave you enough information to be able to solve this problem.