Einzelnen Beitrag anzeigen

Benutzerbild von Helmi
Helmi

Registriert seit: 29. Dez 2003
Ort: Erding, Republik Bayern
3.325 Beiträge
 
Delphi XE2 Professional
 
#6

Re: Probleme mit Property einer Komponente

  Alt 17. Nov 2004, 21:43
ich schätze mal du willst das sehen (guckst du):


Code:
unit TrayIcon;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Menus, ShellApi, ExtCtrls, Dialogs, StdCtrls, Variants;

const
  IconID       = 100;
  WM_TRAYNOTIFY = WM_USER + 1024;
  TRAY_CALLBACK = WM_USER + 20;

type
  TBalloonTipFlags     = (BT_Info, BT_Warning, BT_Error, BT_WinSymbol, BT_Question);
  TBalloonTipDirection = (BT_Left, BT_Middle, BT_Right);

  TTrayIcon            = class(TComponent)
  private
    { Private-Deklarationen }
    IconData             : TNotifyIconData;

    FBalloonTip          : TForm;
    FLabelInfo           : TLabel;
    FLabelTitle          : TLabel;
    FFlagImage           : TImage;
    FForegroundTimer     : TTimer;

    FBalloonTipFlags     : TBalloonTipFlags;
    FBalloonTipDirection : TBalloonTipDirection;
    FBalloonTipTimer     : TTimer;
    FBalloonTipTimeOut   : Integer;
    FBalloonTipTitle     : String;
    FBalloonTipInfo      : String;
    FBalloonTipColor     : TColor;
    FBalloonTipTitleColor : TColor;
    FBalloonTipInfoColor : TColor;
    FBalloonTipAlwaysOnTop: Boolean;
    FBalloonTipAutoSize  : Boolean;

    FIcon                : TIcon;
    FIconVisible         : Boolean;
    FHint                : String;
    FShowHint            : Boolean;
    FShowBalloonTip      : Boolean;
    FPopupMenu           : TPopupMenu;
    FLeftPopup           : Boolean;
    FOnClick             : TNotifyEvent;
    FOnDblClick          : TNotifyEvent;
    FOnMouseDown         : TMouseEvent;
    FOnMouseUp           : TMouseEvent;
    FOnMouseMove         : TMouseMoveEvent;
    FStartMinimized      : Boolean;
    FClicked             : Boolean;

    ShowFirst            : Boolean;
    X_Pos_Icon           : Integer;
    Y_Pos_Icon           : Integer;

    function InitIcon: Boolean;
    function InitBalloonTip: Boolean;
    function FindTrayIcon(IcoDat: TNotifyIconData): TPoint;

    procedure HandleMessage(var Msg: TMessage); message TRAY_CALLBACK;
    procedure PopupAtCursor;
    procedure DoBalloonTipFlags;
    procedure BalloonTip_erzeugen;

    procedure SetIcon(Value: TIcon);
    procedure SetIconVisible(Value: Boolean);
    procedure SetHint(Value: String);
    procedure SetBalloonTipInfo(Value: String);
    procedure SetBalloonTipTitle(Value: String);
    procedure SetBalloonTipAlwaysOnTop(Value: Boolean);
    procedure SetBalloonTipColor(Value: TColor);
    procedure SetBalloonTipAutoSize(Value: Boolean);
    procedure SetShowHint(Value: Boolean);
    procedure SetShowBalloonTip(Value: Boolean);
    procedure SetBalloonTipFlag(Value : TBalloonTipFlags);
    procedure SetBalloonTipDirection(Value: TBalloonTipDirection);
    procedure SetBalloonTipTimeOut(Value: Integer);
    procedure SetBalloonTipTitleColor(Value: TColor);
    procedure SetBalloonTipInfoColor(Value: TColor);
  protected
    { Protected-Deklarationen }
    function ShowIcon: Boolean; virtual;
    function HideIcon: Boolean; virtual;
    function ModifyIcon: Boolean; virtual;
    function ModifyBalloonTip: Boolean; virtual;

    procedure Loaded; override;

    procedure Click; dynamic;
    procedure DblClick; dynamic;
    procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
      X, Y: Integer); dynamic;
    procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
      X, Y: Integer); dynamic;
    procedure MouseMove(Shift: TShiftState; X, Y: Integer); dynamic;

    procedure OnBalloonTipTimer(Sender: TObject);
    procedure OnForegroundTimer(Sender : TObject);

    procedure AppMinimize(Sender: TObject);
  public
    { Public-Deklarationen }
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;

    procedure ShowMainForm;
    procedure HideMainForm;
  published
    { Published-Deklarationen }
    // Properties:
    property Hint: String read FHint write SetHint;

    property BalloonTipInfo: String read FBalloonTipInfo write SetBalloonTipInfo;

    property BalloonTipTitle: String read FBalloonTipTitle write SetBalloonTipTitle;

    property BalloonTipAlwaysOnTop: Boolean read FBalloonTipAlwaysOnTop
      write SetBalloonTipAlwaysOnTop default false;

    property BalloonTipFlags: TBalloonTipFlags read FBalloonTipFlags
      write SetBalloonTipFlag default BT_Info;

    property BalloonTipDirection: TBalloonTipDirection read FBalloonTipDirection
      write SetBalloonTipDirection default BT_Right;

    property BalloonTipTimeOut: Integer read FBalloonTipTimeOut write SetBalloonTipTimeOut
      default 1000;

    property BalloonTipColor: TColor read FBalloonTipColor write SetBalloonTipColor
      default clYellow;

    property BalloonTipTitleColor: TColor read FBalloonTipTitleColor write SetBalloonTipTitleColor
      default clBlack;

    property BalloonTipInfoColor: TColor read FBalloonTipInfoColor write SetBalloonTipInfoColor
      default clBlack;

    property BalloonTipAutoSize: Boolean read FBalloonTipAutoSize
      write SetBalloonTipAutoSize default false;

    property ShowHint: Boolean read FShowHint write SetShowHint
      default false;

    property ShowBalloonTip: Boolean read FShowBalloonTip write SetShowBalloonTip
      default false;

    property Icon: TIcon read FIcon write SetIcon stored true;

    property IconVisible: Boolean read FIconVisible write SetIconVisible
      default false;

    property PopupMenu: TPopupMenu read FPopupMenu write FPopupMenu;

    property LeftPopup: Boolean read FLeftPopup write FLeftPopup
      default False;

    property StartMinimized: Boolean read FStartMinimized write FStartMinimized
      default False;

    // Events:
    property OnClick: TNotifyEvent read FOnClick write FOnClick;
    property OnDblClick: TNotifyEvent read FOnDblClick write FOnDblClick;
    property OnMouseDown: TMouseEvent read FOnMouseDown write FOnMouseDown;
    property OnMouseUp: TMouseEvent read FOnMouseUp write FOnMouseUp;
    property OnMouseMove: TMouseMoveEvent read FOnMouseMove write FOnMouseMove;
  end;

procedure Register;

implementation
  Mit Zitat antworten Zitat