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
sierra20Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MadshiCommented:
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.
0
RBertoraCommented:
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 ;-)
0
RBertoraCommented:
//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 ;-)
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

JaymolCommented:
Make the label transparent.  It gets rid of stuff like that (it simply redraws it quicker!)

John.
0
kretzschmarCommented:
hmm,

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

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

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

Look at the first comment in this question...
0
sierra20Author Commented:
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
0
RBertoraCommented:
>The label have to stay under the cursor when i drag it.

Why?

Rob ;-)
0
sierra20Author Commented:
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
0
kretzschmarCommented:
hi sierra20,

have you tried my suggestion with the panel?

meikl
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sierra20Author Commented:
Hi Meikl,

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

Sierra
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.