Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can i modify the below code to stop flickering of buttons.


procedure TCustomEdit.WMPaint(var Message: TWMPaint);
begin
inherited;
EditLayout.WMPaint(Message);
end;

Here TCustomEdit is the base class for the buttons that flicker.
The problem is with editlayout.
When we remove/comment the editlayout line then flickering doesn't occur.
But, we need editlayout for other functionalities.
Can you suggest on how to modify the editlayout given below is the code part.


procedure TEditLayout.WMPaint(var Message: TWMPaint);
var
iDC: HDC;
r: TRect;
begin
inherited;
if (csDesigning in fEdit.ComponentState) then Exit;
if fFlat then
begin
iDC := GetWindowDC(fEdit.Handle);
try
GetWindowRect(fEdit.Handle, r);
MapWindowPoints(0, fEdit.Handle, r, 2);
Inc(r.Top, 2);
Inc(r.Left, 2);
with fCanvas do
try
Handle := iDC;
if fMouseIn or fEdit.Focused then
Pen.Color := clBtnShadow
else
Pen.Color := clWindow;
PolyLine([r.TopLeft, Point(r.Right, r.Top), r.TopLeft, Point(r.Left, r.Bottom)]);
Inc(r.Top);
Inc(r.Left);
if fMouseIn or fEdit.Focused then
Pen.Color := clWindowText;
PolyLine([r.TopLeft, Point(r.Right, r.Top), r.TopLeft, Point(r.Left, r.Bottom)]);
Dec(r.Left);
if fMouseIn or fEdit.Focused then
begin
Pen.Color := clBtnFace;
PolyLine([Point(r.Left, r.Bottom), r.BottomRight, Point(r.Right, r.Top), r.BottomRight]);
end
else
begin
PolyLine([Point(r.Left, r.Bottom), r.BottomRight]);
Inc(r.Bottom);
PolyLine([Point(r.Left, r.Bottom), r.BottomRight, Point(r.Right, r.Top), r.BottomRight]);
end;
finally
Handle := 0;
end;
finally
ReleaseDC(fEdit.Handle, iDC);
end;
TEditButtons(fCollection).ToggleFlat;
end;
TEditButtons(fCollection).Invalidate;
end;

What I have tried:

Tried removing editlayout. But, it is needed for other purposes. Please suggest on how to edit/modify the Code.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900