【问题标题】:Why does this error keep messing up the XE2 IDE Toolbars?为什么这个错误会一直弄乱 XE2 IDE 工具栏?
【发布时间】:2012-05-15 14:54:36
【问题描述】:

屏幕截图

以下源代码用于产生上述错误。您只需编译程序并确保 IDE 仍在运行(如果关闭 IDE,则不会发生错误),单击按钮 12 到 15 次会弹出错误。

一旦发生错误,切换回 IDE,IDE 的所有工具栏都消失了。您必须关闭 IDE 并再次运行,它们才能重新出现。

源代码

unit MainUnit;

interface

uses
  Winapi.Windows, Winapi.Messages, Winapi.ShlObj, System.SysUtils,
  System.Variants, System.Classes, System.StrUtils, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.StdCtrls;

type
  TMainFrm = class(TForm)
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  MainFrm: TMainFrm;
  hDesktop: HWND;

implementation

{$R *.dfm}

function GetHandle(theHandle: HWND; NotUsed: NativeInt): LongBool; stdcall;
begin
  if (theHandle <> 0) then
  begin
    hDesktop := FindWindowEx(FindWindowEx(theHandle, 0, 'SHELLDLL_DefView',
      nil), 0, 'SysListView32', nil);
  end;
  Result := (hDesktop = 0);
end;

procedure TMainFrm.FormCreate(Sender: TObject);
var
  lpss: TShellState;
begin
  ZeroMemory(@lpss, SizeOf(lpss));
  try
    SHGetSetSettings(lpss, SSF_HIDEICONS, False);
  finally
    Button1.Caption := IfThen(lpss.fHideIcons, 'Show Icons', 'Hide Icons');
  end;
  EnumWindows(@GetHandle, 0);
  Button1.Enabled := (hDesktop <> 0);
end;

procedure TMainFrm.Button1Click(Sender: TObject);
const
  nCmdShow: array [Boolean] of NativeInt = (SW_HIDE, SW_SHOW);
var
  lpss: TShellState;
begin
  ZeroMemory(@lpss, SizeOf(lpss));
  try
    SHGetSetSettings(lpss, SSF_HIDEICONS, False);
    ShowWindow(hDesktop, nCmdShow[lpss.fHideIcons]);

    lpss.fHideIcons := (not BOOL(lpss.fHideIcons));
    Button1.Caption := IfThen(lpss.fHideIcons, 'Show Icons', 'Hide Icons');
  finally
    SHGetSetSettings(lpss, SSF_HIDEICONS, True);
  end;
end;

end.

应用程序屏幕截图

任何帮助将不胜感激。

更新

IDE 工具栏不再消失,错误也不再出现,感谢 TOndrej 提供有关关闭“Profiler 工具栏”的信息。现在我得到一个非常烦人的闪烁,有时需要 10 到 15 秒才能恢复正常。

【问题讨论】:

  • 我建议你试试Delphi XE,如果可以的话,它看起来更稳定。

标签: windows delphi windows-7 ide delphi-xe2


【解决方案1】:

您是否安装了 AQTime?如果您只是隐藏 Profiler 工具栏,问题似乎就消失了。

【讨论】:

  • 我猜它与AQTime无关。我没有它,但是当我的机器上显示或隐藏图标时,所有窗口(不仅是 Delphi IDE)上的所有工具栏都会闪烁。但是我没有收到 A call to an OS function failed 错误。
  • @TLama 闪烁无关,错误可能是;每次显示 Profiler 工具栏时都可重现,隐藏时无法重现。
  • 我没想到会闪烁。你得到了我的 +1,因为它只是证实了你的理论,因为我没有安装 AQTime ;-)
  • @TLama 谢谢 :-) 闪烁可以通过TApplication.CheckIniChange -> TScreen.IconFontChanged 来解释,它将CM_SYSFONTCHANGED 广播到递归地传播给孩子的所有 IDE 表单。工具栏通过重新创建它们的窗口来处理此消息,这会导致闪烁。
  • @eyeClaxton 很有趣,因为您从未在原始问题中提到闪烁是一个问题。我认为问题在于 IDE 的错误和随后的不稳定性——这似乎是由 AQTime 引起的。如果您想消除闪烁 - 这是另一个问题 - 也许您可以接受的解决方案是简单地从设计包中关闭 UpdateMetricSettings
猜你喜欢
  • 2017-05-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-12-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多