0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Delphi】タスクバーボタンを個別に表示する

0
Last updated at Posted at 2026-10-28

はじめに

タスクバーボタンは同じアプリケーションを起動したときにグループ化されますが、これを個別に表示する事もできます。

image.png

タスクバーボタン は Windows 7 から使えます。

実装

とは言っても SetCurrentProcessExplicitAppUserModelID() API を呼ぶだけです。

つまりは AppUserModelID が別ならボタンも別になります。

ソースコード

以下のサンプルコードでは、起動時のパラメータによりタスクバーボタンがグループ化されます。

program Project1;

uses
  System.SysUtils,
  Vcl.Forms,
  Winapi.ShlObj, // 追加
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

var
  AppUserModelID, ID: string;
begin
  if ParamCount = 0 then
    ID := 'Default'
  else
    ID := ParamStr(1);
  AppUserModelID := 'MyCompany.MyProduct.' + ID;
  SetCurrentProcessExplicitAppUserModelID(PChar(AppUserModelID));

  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

AppUserModelID はアプリケーション固有のものを指定する必要があります 1。

使い方

次のように実行すると、

Project1.exe
Project1.exe
Project1.exe 1
Project1.exe 1

image.png

それぞれでグループ化されます 2。

注意点

ジャンプリストを使っている場合には、SetCurrentProcessExplicitAppUserModelID() で指定したものと同じ AppUserModelID を ApplicationID プロパティに設定する必要があります

Project1.dpr
  Application.CreateForm(TForm1, Form1);
  Form1.FAppUserModelID := ApplicationID; // ApplicationID を Form1 に渡す
  Application.Run;
Unit1.pas
  public
    { Public 宣言 }
    FAppUserModelID: string; // 追加
  end;

  ...

  JumpList1.ApplicationID := FAppUserModelID; // ApplicationID を設定

See also:

おわりに

モード別にジャンプリストを切り替えるのに使えます。

See also:

索引

[ ↑ 目次へ ]

  1. バージョン情報にある ProgramID とは無関係です。同一のものにする必要はありません。 ↩

  2. Windows 11 ではマウスオーバーしないとグループ化されているか判断できません。画像左のタスクバーボタンも実際にはグループ化されています。 ↩

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?