zoukankan      html  css  js  c++  java
  • 一个简单的系统托盘程序

    Delphi System Tray Application,版本高于D7时设置Application.ShowMainForm := False;在隐藏的时候,任务栏不显示。

    代码
    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, ShellAPI, AppEvnts;
    const
    WM_ICONTRAY
    = WM_USER + 100;
    type
    TForm1
    = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    private
    { Private declarations }
    TrayIconData: TNotifyIConData;
    public
    { Public declarations }
    procedure TrayMessage(var aMsg:TMessage);message WM_ICONTRAY;
    end;
    var
    Form1: TForm1;

    implementation
    {$R *.dfm}

    procedure TForm1.FormCreate(Sender: TObject);
    begin
    with TrayIconData do
    begin
    cbSize :
    = SizeOf(TrayIconData);
    wnd :
    = Self.Handle;
    uID :
    = 0;
    uFlags :
    = NIF_MESSAGE + NIF_ICON + NIF_TIP;
    uCallbackMessage :
    = WM_ICONTRAY;
    hIcon :
    = Application.Icon.Handle; //LoadIcon(HInstance,'newIcon'); 加载自己的Icon
    StrPCopy(szTip,Application.Title);
    end;
    Shell_NotifyIcon(NIM_ADD,@TrayIconData);
    end;

    procedure TForm1.FormDestroy(Sender: TObject);
    begin
    Shell_NotifyIcon(NIM_DELETE,@TrayICONData);
    end;

    procedure TForm1.TrayMessage(var aMsg: TMessage);
    begin
    case aMsg.LParam of
    WM_LBUTTONDOWN:
    begin
    ShowMessage(
    'Left button clicked - let''s SHOW the Form!');
    Application.MainForm.Show;
    end;
    WM_RBUTTONDOWN:
    begin
    ShowMessage(
    'Right button clicked - let''s HIDE the Form!');
    Application.MainForm.Hide;
    end;
    end;
    end;

    end.
  • 相关阅读:
    DOM编程
    BOM编程
    JavaScript
    CSS
    HTML入门
    shiro与项目集成开发
    shiro授权测试
    散列算法
    shiro认证流程
    spring boot 入门及示例
  • 原文地址:https://www.cnblogs.com/Jekhn/p/1918743.html
Copyright © 2011-2022 走看看