FMX(FireMonkey)可以轻松实现很多VCL无法或难以实现的特效,所以将FMX程序作为界面,打包入DLL由VCL程序调用,是一个不错的方案。为了程序的完整性,你不想看见FMX程序在任务栏上显示图标。可是普通的Windows函数似乎没有作用,比如你取得FMX窗体的句柄后,使用ShowWindow函数隐藏任务栏图标,结果是毫无作用。其实原因很简单,只是你使用的句柄不正确而已。

正确的源代码我贴出来,具体我就不解释了,相信有基础的人都能看懂。

unit Unit1;

interface

uses
  Winapi.Windows,
  Winapi.Messages,
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Platform.Win,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Controls.Presentation, FMX.StdCtrls;

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

var
  Form1: TForm1;

implementation

{$R *.fmx}

procedure TForm1.Button1Click(Sender: TObject);
begin
  //隐藏主程序在任务栏的图标
  ShowWindow(ApplicationHWND, SW_HIDE);
  //隐藏主程序在alt+tab中的图标
  SetWindowLong(ApplicationHWND, GWL_EXSTYLE, WS_EX_TOOLWINDOW Or GetWindowLong(ApplicationHWND, GWL_EXSTYLE));
end;

end.

此代码在Delphi XE8中编译,调试正确。