「なでしこv1」開発掲示板

なでしこv1のバグや要望を書き込む掲示板
[一覧へ] > (@671) [低] [解決]
@671■ (#2110) タスクトレイのバルーン通知の追加 - うぇいく (2013-03-31 05:02) /低 アイデア
【その他】
以下のような感じで追加できそうな感じです。
---- frmNakoU.pas(31)ぐらいに追加
  TNotifyIconDataVistaA = record
    cbSize:Integer;
    Wnd:HWND;
    uID:Integer;
    uFlags:Integer;
    uCallbackMessage:Integer;
    hIcon:HICON;
    szTip:array[0..127] of char;
    dwState:Integer;
    dwStateMask:Integer;
    szInfo:array[0..255] of char;
    uTimeout:Integer;
    szInfoTitle:array[0..63] of char;
    dwInfoFlags:Integer;
    guidItem:TGUID;
    hBalloonIcon:HICON;
  end;
---- 147行目ぐらい
  private
    NotifyIcon: TNotifyIconDataVistaA;
    NotifyIconSize: Integer; // V1(NT)=88 V2(2K)=488 V3(XP)=504 V4(Vista)=508
---- 152行目ぐらい
  public
    IsLiveTasktray: boolean;
    dwBalloonOption: Integer;
    bBalloonRealtime: boolean;
    procedure InitTasktray;
    procedure FinishTasktray;
    procedure ChangeTrayIcon;
    procedure MovetoTasktray(HideForm:Boolean = True); // タスクトレイへ移動
    procedure LeaveTasktray(RestoreForm:Boolean = True);  // タスクトレイを離れる
    procedure ShowBalloon(message:string); // バルーン表示
    procedure HideBalloon(); // バルーン削除
----- 1553ぐらいのFinishTasktrayのcbSizeの設定を変更
    cbSize := NotifyIconSize;
----- 1567ぐらいのInitTasktrayを変更
procedure TfrmNako.InitTasktray;
begin
  if IsLiveTasktray then exit;
  NotifyIconSize := 508; // V4(Vista)のサイズ
  with NotifyIcon do
  begin
    cbSize := NotifyIconSize;
    Wnd := Handle;
    uID := 1;
    uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP or $00000080; // NIF_SHOWTIP=$00000080
    uCallbackMessage := WM_NotifyTasktray;
    if Self.Icon.Handle > 0 then
      hIcon := Self.Icon.Handle
    else
      hIcon := Application.Icon.Handle;
    StrLCopy(@szTip[0],PChar(Self.Caption), 127);
  end;
  if not Shell_NotifyIcon(NIM_ADD,@NotifyIcon) then
  begin
    NotifyIconSize := 504; // V3(XP)のサイズ
    NotifyIcon.uFlags := NotifyIcon.uFlags and $ffffff7f; // NIF_SHOWTIP=$00000080
    NotifyIcon.cbSize := NotifyIconSize;
    if not Shell_NotifyIcon(NIM_ADD,@NotifyIcon) then
    begin
      NotifyIconSize := 488; // V2(2K)のサイズ
      NotifyIcon.cbSize := NotifyIconSize;
      if not Shell_NotifyIcon(NIM_ADD,@NotifyIcon) then
      begin
        NotifyIconSize := 88; // V1(NT)のサイズ
        NotifyIcon.cbSize := NotifyIconSize;
        StrLCopy(@(NotifyIcon.szTip[0]),PChar(Self.Caption), 63);
        Shell_NotifyIcon(NIM_ADD,@NotifyIcon);
      end;
    end;
  end;
  IsLiveTasktray := True;
end;
---- 1634あたりにShowballoonとHideBalloonを追加
procedure TfrmNako.ShowBalloon(message:String);
begin
  if not IsLiveTasktray then exit;
  if NotifyIconSize = 88 then exit;

  with NotifyIcon do
  begin
    cbSize := NotifyIconSize;
    Wnd := Handle;
    uID := 1;
    uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP or $00000010; // NIF_INFO=$00000010
    if NotifyIconSize = 508 then
    begin
      uFlags := uFlags or $00000080; // NIF_SHOWTIP=$00000080
      if bBalloonRealtime then
        uFlags := uFlags or $00000040;  // NIF_REALTIME=$00000040
    end;
    uCallbackMessage := WM_NotifyTasktray;
    if Self.Icon.Handle > 0 then
      hIcon := Self.Icon.Handle
    else
      hIcon := Application.Icon.Handle;
    if NotifyIconSize = 508 then
      if (dwInfoFlags and $0000000f) = $00000004 then // NIIF_USER=$00000004
        if Self.Icon.Handle > 0 then
          hBalloonIcon := Self.Icon.Handle
        else
          hBalloonIcon := Application.Icon.Handle;
    StrLCopy(@szTip[0],PChar(Self.Caption), 127);
    StrLCopy(@szInfoTitle[0],PChar(Self.Caption), 63);
    StrLCopy(@szInfo[0],PChar(message), 255);
    dwInfoFlags := dwBalloonOption;
    if NotifyIconSize = 488 then
      dwInfoFlags := dwInfoFlags and $0000000f; // NIF_ICON_MASK=$0000000f
  end;
  Shell_NotifyIcon(NIM_MODIFY, @NotifyIcon);
  IsLiveTasktray := True;
end;

procedure TfrmNako.hideBalloon();
begin
  if not IsLiveTasktray then exit;
  if NotifyIconSize = 88 then exit;

  with NotifyIcon do
  begin
    cbSize := NotifyIconSize;
    Wnd := Handle;
    uID := 1;
    uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP or $00000010; // NIF_INFO=$00000010
    if NotifyIconSize = 508 then
      uFlags := uFlags or $00000080; // NIF_SHOWTIP=$00000080
    if Self.Icon.Handle > 0 then
      hIcon := Self.Icon.Handle
    else
      hIcon := Application.Icon.Handle;
    StrLCopy(@szTip[0],PChar(Self.Caption), 127);
    StrLCopy(@szInfoTitle[0],PChar(''), 63);
    StrLCopy(@szInfo[0],PChar(''), 255);
    dwInfoFlags := dwBalloonOption;
    if NotifyIconSize = 488 then
      dwInfoFlags := dwInfoFlags or $0000000f; // NIF_ICON_MASK=$0000000f
  end;
  Shell_NotifyIcon(NIM_MODIFY, @NotifyIcon);
  IsLiveTasktray := True;
end;
----- 1768あたりのChangeTrayIconを変更
procedure TfrmNako.ChangeTrayIcon;
begin
  if not IsLiveTasktray then exit;

  with NotifyIcon do
  begin
    cbSize := NotifyIconSize;
    Wnd := Handle;
    uID := 1;
    uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;
    if NotifyIconSize = 508 then
      uFlags := uFlags or $00000080; // NIF_SHOWTIP=$00000080
    uCallbackMessage := WM_NotifyTasktray;
    if Self.Icon.Handle > 0 then
      hIcon := Self.Icon.Handle
    else
      hIcon := Application.Icon.Handle;
    if NotifyIconSize = 88 then
      StrLCopy(@szTip[0],PChar(Self.Caption), 63)
    else
      StrLCopy(@szTip[0],PChar(Self.Caption), 127)
  end;
  Shell_NotifyIcon(NIM_MODIFY, @NotifyIcon);
  IsLiveTasktray := True;
end;
---- vnako_function.pasの6977あたりの変数宣言にoptを追加
  var e: TfrmNako; ico: TIcon; icoCreate: TjvIcon; s: string; bmp: TBitmap;opt : Integer;
---- 7042あたりにバルーン系のコマンドを追加
    if cmd = 'タスクトレイバルーン表示' then e.showBalloon(hi_str(v)) else
    if cmd = 'タスクトレイバルーン非表示' then e.hideBalloon() else
    if cmd = 'タスクトレイバルーンオプションSET' then
    begin
      s := hi_str(v);
      opt := 0;
      if Pos('アイコン無し',  s) > 0            then opt := $00000000 { NIIF_NONE=$00000000 } else
      if Pos('エラーアイコン',  s) > 0          then opt := $00000003 { NIIF_ERROR=$00000003 } else
      if Pos('通知アイコン',  s) > 0            then opt := $00000001 { NIIF_INFO=$00000001 } else
      if Pos('警告アイコン',  s) > 0            then opt := $00000002 { NIIF_WARNING=$00000002 } else
      if Pos('アプリケーションアイコン',s) > 0  then opt := $00000004; { NIIF_USER=$00000004 }
      if (Pos('音無し',  s) > 0) or (Pos('無音',  s) > 0)  then opt := opt + $00000010; { NIIF_NOSOUND=$00000010 }
      e.dwBalloonOption := opt;
      if Pos('リアルタイム',s) > 0  then e.bBalloonRealtime := true
      else e.bBalloonRealtime := false;
    end else
    if cmd = 'タスクトレイバルーンオプションGET' then
    begin
      opt := e.dwBalloonOption;
      s := '';
      if (opt and $00000010) <> 0 then begin s:='/無音'; opt:=opt-$00000010; end;
      if opt=$00000000 then s:='アイコン無し'+s;
      if opt=$00000003 then s:='エラーアイコン'+s;
      if opt=$00000002 then s:='警告アイコン'+s;
      if opt=$00000001 then s:='通知アイコン'+s;
      if opt=$00000004 then s:='アプリケーションアイコン'+s;
      e.dwBalloonOption := opt;
      if e.bBalloonRealtime then s:=s+'/リアルタイム';
      Result := hi_var_new; hi_setStr(Result, s);
    end else
---- vnako.nakoの486あたりにバルーン系のコマンドを追加
 ・タスクトレイバルーン表示(Vを)~
   VCL_COMMAND(オブジェクト, "タスクトレイバルーン表示",V)
 ・タスクトレイバルーン非表示()~
   VCL_COMMAND(オブジェクト, "タスクトレイバルーン非表示",0)
 ・{非公開}バルーンオプション設定(V)~VCL_COMMAND(オブジェクト, "タスクトレイバルーンオプションSET",V)
 ・{非公開}バルーンオプション取得~VCL_COMMAND(オブジェクト, "タスクトレイバルーンオプションGET","")
 ・タスクトレイバルーンオプション ←バルーンオプション設定 →バルーンオプション取得
----

(#2171) r293で対応 - クジラ飛行机 (2013-06-03 18:38) /低 確認待ち
version 1.537で試せるようになります。
丁寧にありがとうございます!
感謝です。

(#2281) 対応済みなので完了とします - クジラ飛行机 (2014-02-28 11:00) /低 解決

(#2110)へ返信する:

👆お手数ですが、いたずら防止のために、「真夏」の読み方を記入してください。

編集時に使うキーを入力(省略可能)

画像ファイル(最大300KB)を添付可能