为什么这个错误会影响XE2 IDE工具栏呢?

eye*_*ton 5 windows ide delphi windows-7 delphi-xe2

屏幕截图

在此输入图像描述

以下源代码用于产生上述错误.您所要做的就是编译程序并确保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.
Run Code Online (Sandbox Code Playgroud)

应用程序屏幕截图

在此输入图像描述

任何帮助将不胜感激.

UPDATE

IDE工具栏不再消失,并且错误不再出现,这要归功于TOndrej关于关闭"Profiler工具栏"的信息.现在我得到一个非常讨厌的闪烁,有时需要10到15秒才能恢复正常.

Ond*_*lle 5

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

  • @TLama谢谢:-)闪烁可以通过`TApplication.CheckIniChange` - >`TScreen.IconFontChanged`解释,它将`CM_SYSFONTCHANGED`广播到所有以递归方式传播给子节点的IDE表单.工具栏通过重新创建窗口来处理此消息并导致闪烁. (2认同)