Link to home
Start Free TrialLog in
Avatar of sierra20
sierra20

asked on

Label always flickering

Hi

I have a form with a couple of label in it.
I can drag each one at a different position in the form.
But when i drag it, the label always flick.

When i drag the label, i use onmousemove to know the position of the cursor, then i move the label under the cursor, its at this moment that the klickering occur.

exemple :
procedure mousemove(sender:tobject; shifgt:tshiftstate; x,y:integer);
Begin
 Label.left:=x-4;
 Label.top:=y-4;
end;

Thanks

Sierra
Avatar of Madshi
Madshi

Try this:

Label.SetBounds(x-4, y-4, Label.Width, Label.Height);

Play also with the "DoubleBuffered" property.

Perhaps "Label.DoubleBuffered := true" or "Form1.DoubleBuffered := true".

Does this help?

Regards, Madshi.
Avatar of RBertora
Why not just make sure that the label never floats under your cursor.

You can do this by adding a constant say
16 to your x and y values in all your calculations...

Rob ;-)
//this looks fine with no flickering..

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  Label1.Top := Y-16;
  Label1.Left := X-16;
end;

//just makes sure that the label never overlaps the cursor
Rob ;-)
Make the label transparent.  It gets rid of stuff like that (it simply redraws it quicker!)

John.
hmm,

just place a panel (alignment alclient) on your form and place on it your labels

meikl
Try on forms create :
MyLabel.Parent.DoubleBuffered := True;

Where MyLabel is your Label's name.
You Won't get a flicker again..
Well, I've already suggested that!!

Look at the first comment in this question...
Avatar of sierra20

ASKER

Hi

I dont see this property (doubleBuffered), i work with delphi 3....

The label have to stay under the cursor when i drag it.

I forget to tell that there is some other code in the procedure Mousemove.

Sierra
>The label have to stay under the cursor when i drag it.

Why?

Rob ;-)
Because the label represent an object that the user can move to an other emplacement. When the user will click on the mouse, the label will take this position.

Sierra
ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany 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
Hi Meikl,

Yes its work, i just dont understand why the label dont flick now when you put it on a panel....

Sierra