【发布时间】:2010-11-11 14:38:02
【问题描述】:
所以,这是我刚刚阅读的讨论: http://www.mail-archive.com/delphi@delphi.org.nz/msg02315.html
BeginUpdate 和 EndUpdate 不是我需要的程序...
覆盖 API 调用?我试图从 ComCtrls 单元获取更新程序代码,没有找到 nut...
也许你可以在这里发布一个代码来修复状态栏组件的闪烁,如果其中唯一的文本发生变化?我的意思是 - 类似 TextUpdate 或某种 TCanvas 方法或 PanelsRepaint ...?
闪烁是由这段代码引起的:
Repeat
BlockRead(Fp, BuffArrayDebug[LineIndex], DataCapac, TestByteBuff); // DataCapac = SizeOf(DWORD)
ProgressBar1.StepIt;
if RAWFastMode.Checked then begin // checks for fast mode and modifyies progressbar
if BuffArrayDebug[LineIndex] = 0 then begin ProgressBar2.Max := FileSize(Fp) - DataCapac; ProgressBar2.Position := (LineIndex + 1) * DataCapac; LineDecr := True; end;
end else begin ProgressBar2.Max := FileSize(Fp); ProgressBar2.Position := LineIndex * DataCapac end;
if PreviewOpn.Caption = '<' then begin // starts data copying to preview area if expanded
Memo1.Lines.BeginUpdate;
if (LineIndex mod DataCapac) > 0 then HexMerge := HexMerge + ByteToHex(BuffArrayDebug[LineIndex]) else
begin
Memo1.Lines.Add(HexMerge); HexMerge := '';
end;
Memo1.Lines.EndUpdate;
end;
StatusBar1.Panels[0].Text := 'Line: ' + Format('%.7d',[LineIndex]) + ' | Data: ' + Format('%.3d',[BuffArrayDebug[LineIndex]]) + ' | Time: ' + TimeToStr(Time - TimeVarStart); StatusBar1.Update;
if FindCMDLineSwitch(ParamStr(1)) then begin
TrayIcon.BalloonTitle := 'Processing ' + ExtractFileName(RAWOpenDialog.FileName) + ' and reading ...';
TrayIcon.BalloonHint := 'Current Line: ' + inttostr(LineIndex) + #10#13 + ' Byte Data: ' + inttostr(TestByteBuff) + #10#13 + ' Hex Data: ' + ByteToHex(TestByteBuff);
TrayIcon.ShowBalloonHint;
end;
Inc(LineIndex);
Until EOF(Fp);
有什么想法吗?
此链接 (http://www.stevetrefethen.com/blog/UsingTheWSEXCOMPOSITEWindowStyleToEliminateFlickerOnWindowsXP.aspx) 有评论,并且有有效的程序(无论如何都不会闪烁),但它是 VVVVVVVEEEEEERRRRYYYYYY 慢!
1 type
2 TMyForm = class(TForm)
3 protected
4 procedure CreateParams(var Params: TCreateParams); override;
5 end;
6
7 ...
8
9 procedure TMyForm.CreateParams(var Params: TCreateParams);
10 begin
11 inherited;
12 // This only works on Windows XP and above
13 if CheckWin32Version(5, 1) then
14 Params.ExStyle := Params.ExStyle or WS_EX_COMPOSITED;
15 end;
16
另外——目标不是表单,而是StatusBar ...如何将此方法分配给statusbar?
【问题讨论】:
-
我的状态栏没有闪烁。你怎么做才能让它闪烁? LockWindowUpdate 仅在您大量更改 UI 并且暂时不想更新 UI 时才有帮助。
-
@Lars: LockWindowUpdate() 不应该用于减少闪烁。事实上,在桌面合成的时代,根本不应该使用它。请参阅 blogs.msdn.com/oldnewthing/archive/2007/02/22/1742084.aspx、blogs.msdn.com/oldnewthing/archive/2007/02/23/1747713.aspx 以及 Raymond Chen 的相关帖子。
-
嗯,是的,我只是将它作为可能的解决方案的一部分添加...感谢链接,mghie ;)
-
你用的是什么版本的Delphi?
-
我在状态栏中看到闪烁的唯一情况是当我试图强制重绘比刷新显示器更快时。你说的是这个吗?如果没有,我不确定你看到了什么。您能否提供一个演示该问题的示例程序/代码?
标签: windows delphi graphics controls