2012-05-07 47 views
5

屏幕截图为什么这个错误不断搞乱XE2 IDE工具栏?

enter image description here

下面的源代码被用来生产上述错误。所有你需要做的就是编译程序并确保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. 

应用屏幕截图

enter image description here

任何帮助将不胜感激。

UPDATE

的IDE工具栏不再消失,误差不会再出现,这要归功于TOndrej关于关闭“剖析工具栏”中的信息。现在我得到一个非常恼人的闪烁,有时需要10到15秒才能恢复正常。

+0

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

回答

5

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

+0

我想这不会与AQTime有关。我没有它,但当图标在我的机器上显示或隐藏时,所有窗口上的所有工具栏(不仅是Delphi IDE)都会闪烁。但是,我没有得到*调用操作系统函数失败*错误。 – TLama

+0

@TLama闪烁是不相关的,错误可能是;每次显示Profiler工具栏时都可以重现,隐藏时无法重现。 –

+0

我没想到闪烁。你得到我的+1,因为它只是证实了你的理论,因为我没有安装AQTime ;-) – TLama

相关问题