Screen Shot

The following source code was used to produce the error above. All you have to do is compile the program and make sure the IDE is still running (the error does NOT happen if the IDE is closed), click the button 12 to 15 times and the error will popup.
Once the error has occurred, switch back to the IDE, all the toolbars for the IDE have then disappeared. You have to shut down the IDE and run again, for them to reappear.
Source Code
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.
Application Screen Shot

Any help would be greatly appreciated.
UPDATE
The IDE toolbars no longer disappear, and the error doesn't appear anymore, thanks to TOndrej for the information about turning off the "Profiler toolbar". Now I get a very annoying flicker that sometimes takes 10 to 15 seconds to return back to normal.
Do you have AQTime installed? The problem seems to disappear if you simply hide the Profiler toolbar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With