Recent

Author Topic: Image and Label Refrash[resolved]  (Read 10247 times)

Drakon

  • New Member
  • *
  • Posts: 15
Image and Label Refrash[resolved]
« on: January 26, 2010, 02:49:10 pm »
In my old application in Delphi, on the desktop there was an image that was the menu and labels that change color when the mouse hovers over them, now in lazarus the picture is flashing, somebody knows any solution because I tried various command Update without success.

Can anyone help me? or already experienced the same problem?
%)
« Last Edit: January 30, 2010, 02:10:09 am by Drakon »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8112
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Image and Label Refrash
« Reply #1 on: January 27, 2010, 04:35:33 am »
Quote
now in lazarus the picture is flashing
You mean flickers? Try setting DoubleBuffered to true.

Drakon

  • New Member
  • *
  • Posts: 15
Re: Image and Label Refrash
« Reply #2 on: January 27, 2010, 02:56:44 pm »
let me explain, I have a label, which will be the hours, and I also have a timer that in intervalors of 1000 milliseconds Trading caption for the current hours.
But the label flashes this exchange, as if he was "visible: = False" and "Visible: = True" in this moment of exchange of label

Zaher

  • Hero Member
  • *****
  • Posts: 571
    • parmaja.com
Re: Image and Label Refrash
« Reply #3 on: January 27, 2010, 10:57:05 pm »
Do use for update TLabel
Label1.Visible := False;
Label1.Visible := True;

if yes you must use
Label1.Refresh;

Wodzu

  • Full Member
  • ***
  • Posts: 171
Re: Image and Label Refrash
« Reply #4 on: January 27, 2010, 11:23:57 pm »
Drakon.

It works here. What I did:

1. New Application
2. TImage on the form -> loaded some picture
3. Puted TLabel on TImage with a BIG font
4. Puted TTimer.
5. Filled OnTimer event
Code: [Select]
procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Label1.Caption := DateTimeToStr(Now);
end;

Works without flickering!

Drakon

  • New Member
  • *
  • Posts: 15
Re: Image and Label Refrash
« Reply #5 on: January 28, 2010, 10:41:04 pm »
thanks to two for the attempted solution, but still the problem persists,
is it because I am using windows seven?, Wodzu you understood my problem perfectly, but like many attempts my funcionatam not, his did not work, you have some other possible solution to this?


see example the my problem
http://rapidshare.com/files/342604723/problem.zip.html
« Last Edit: January 28, 2010, 11:12:18 pm by Drakon »

malcome

  • Jr. Member
  • **
  • Posts: 76
Re: Image and Label Refrash
« Reply #6 on: January 29, 2010, 04:46:34 am »
Certainly flashing on windows vista with "Classic" theme.
but no flashing with "Windows Vista" theme.
Probably it is a problem of Laz.

Wodzu

  • Full Member
  • ***
  • Posts: 171
Re: Image and Label Refrash
« Reply #7 on: January 29, 2010, 08:51:52 am »
Drakon, I was testing my example on Windows 7.

As malcome said, it could be the theme related problem.
What theme are you using?

I'll check differen themes with your example when I get back from work.


Drakon

  • New Member
  • *
  • Posts: 15
Re: Image and Label Refrash
« Reply #8 on: January 29, 2010, 07:54:59 pm »
Wodzu, what malcom said the problem can be really, I'm currently in my work,
but coming home test immediately and return it to you, really I am using
classic theme of Windows 7. Thank you all for your attention!

Zaher

  • Hero Member
  • *****
  • Posts: 571
    • parmaja.com
Re: Image and Label Refrash
« Reply #9 on: January 29, 2010, 08:57:06 pm »
I guess the problem in EreaseBackground and Paint
the Background filled with back color twice before Label painted
try to stop paint background
Code: [Select]
 public
    procedure EraseBackground(DC: HDC); override;

procedure TMyForml.EraseBackground(DC: HDC);
begin
end;
but that make problem with you, if happned paint the background in Paint

Code: [Select]
procedure TMyPanel.Paint;
begin
  inherited;
  Canvas.Brush.Color := Color;
  Canvas.Brush.Style := bsSolid;
  Canvas.FillRect(ClientRect);
end;


Because there is a time between WM_ERASEBKGND and the WM_Paint message.
« Last Edit: January 29, 2010, 08:59:19 pm by Zaher »

Drakon

  • New Member
  • *
  • Posts: 15
Re: Image and Label Refrash
« Reply #10 on: January 30, 2010, 02:09:45 am »
hello, everyone, the real problem was the theme when I started using the normal theme, then the problems are over. Thanks to everyone who helped me when the response to Zaher, unfortunately my application works well with images then it does not like me to give it up, but the background color is the same label, I had already tried that.