下面的源代码被用来生产上述错误。所有你需要做的就是编译程序并确保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.
应用屏幕截图
任何帮助将不胜感激。
UPDATE
的IDE工具栏不再消失,误差不会再出现,这要归功于TOndrej关于关闭“剖析工具栏”中的信息。现在我得到一个非常恼人的闪烁,有时需要10到15秒才能恢复正常。
我建议你试试Delphi XE,如果可以的话,它看起来更稳定。 – none