Code Monkey home page Code Monkey logo

fmx-trayicon's Introduction

FMX-TrayIcon

Add more feature base on https://bitbucket.org/JunHosokawa/trayicon


#TrayIcon

##Overview

The TrayIcon library displays an icon in TaskTray / StatusBar and sets up a popup menu.

ExecImage

##Environment

Item Description
Environment Delphi, RAD Studio
Version Tokyo or later
Framework FireMonkey
Support OS Windows, macOS

##Files

Files Description
LICENSE.txt License
Readme.md This file
sample.pngt For readme file
PK.TrayIcon.pas TrayIcon Source
PK.TrayIcon.Default.pas TrayIcon Source for Windows
PK.TrayIcon.Win.pas TrayIcon Source for macOS
PK.TrayIcon.Mac.pas TrayIcon Source for macOS

##Usage

Add the folder of the above file to the search path.
Add PK.TrayIcon to the uses block.

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,  
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,  
  PK.TrayIcon; // <- Add

Call TTrayIcon.Create to create a TTrayIcon instance and call Methods.

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    FTrayIcon: TTrayIcon;
  public
  end;

implementation

procedure TForm1.FormCreate(Sender: TObject);
var
  Bmp: TBitmap;
begin
  // Generate TaskTray Icon library
  FTrayIcon := TTrayIcon.Create;

  // Event when the icon itself is clicked (Windows Only)
  FTrayIcon.RegisterOnClick(TrayIconClickHandler);
  FTrayIcon.RegisterOnDblClick(TrayIconClickHandler);

  // Menu setting
  FTrayIcon.AddMenu('MenuItem1', MenuClickedHandler);
  FTrayIcon.AddMenu('MenuItem2', MenuClickedHandler);
  FTrayIcon.AddMenu('-', nil);
  FTrayIcon.AddMenu('MenuItem3', MenuClickedHandler);

  // Icon registration
  // An icon is an instance of TBitmap. Here we are extracting from ImageList
  // Bmp := ImageList1.Bitmap(TSizeF.Create(24, 24), 0);
  // FTrayIcon.RegisterIcon('Normal', Bmp);   

  // Bmp := ImageList1.Bitmap(TSizeF.Create(24, 24), 1);
  // FTrayIcon.RegisterIcon('Error', Bmp);   

  // Specify the image to use (Please note that it is not displayed unless specified!)
  // FTrayIcon.ChangeIcon('Normal', 'HintText'); 

  // Displayed in TaskTray / StatusBar
  FTrayIcon.Apply('APPNAME');
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  FTrayIcon.DisposeOf;
end;

procedure TForm1.MenuClickedHandler(Sender: TObject);
begin
  ShowMessage('The menu was clicked!');
end;

procedure TForm1.TrayIconClickHandler(Sender: TObject);
begin
  ShowMessage('TaskTray icon was clicked!');
end;

##Known issues H2161 comes out in Windows environment This is because FMX and VCL read the same cursor resources, there is no particular problem.

##Contact [email protected]
http://twitter.com/pik

#LICENSE Copyright (c) 2018 HOSOKAWA Jun
Released under the MIT license
http://opensource.org/licenses/mit-license.php

fmx-trayicon's People

Contributors

ponypc avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

fmx-trayicon's Issues

Popup menu autohide

Cannot figure out how to hide it when clicking on desktop or other windows. Hides only on clicking menu item or tray icon.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.