TNOTIFYICON control 1.01

zhaozj2021-02-11  168

TNOTIFYICON Control 1.01 (Build Use Delphi 3.0) Description:

effect:

The notification area adds icons and can be displayed, hidden, and modifies this icon.

Properties:

Notifyicon: TICON wants to add icon in the notification area

Isvisible: Boolean NotifyiCon Displayed Properties

Title: String Notification Area Tips (up to 64 characters)

PopupMenu: TPopupMenu Click on the menu of the notification area icon

PopupStyle: Way to pop up menu

TPopupStyle = set of

(Left_Click, Right_Click, Left_DBClick, Right_DbClick);

Method:

Showicon Displays the icon on the notification area

Hideicon hides the icon on the notification area

Modifyicon Modify the icon on the notification area (if isvisible = false, no display)

Create (Aowner: Tcomponent); OVERRIDE; Constructor

DESTROY; OVERRIDE; destructor

Events:

OnConMouseDown:

PROCEDURE (Sender: Tobject; x, Y: Word; Whobutton: twhobutton) of

Object;

(

When mouse click on the icon on the notification area, x, y is the coordinates of mouse on the screen,

Whobutton = B_LEFT is click the left button, whomutton = b_right is right-click,

)

Onicondoucast:

PROCEDURE (Sender: Tobject; x, Y: Word; Whobutton: twhobutton) of

Object;

(

When the mouse double-click the icon on the notification area, X, Y is the coordinates of mouse on the screen,

Whobutton = b_left is double click on the left button, whomutton = b_right is right-click,

)

About Demo:

This demo gives the basic usage of TNotifyicon.

Contains files:

Notifyicon.dcr

Notifyicon.pas

Demounit.PAS

Demounit.dfm

Popunit.pas

PopUnit.dfm

Demo.dpr

Readme.txt

statement:

TNOTIFYICON control V 1.01

1. This is a free control.

2. If you use it, please send an e-mail to the author, thank you.

3 I used success on Delphi3.0 & 4.0

4. To spread it, please distribute the above 8 files

Author Nanchang University Calculation Department 95 (1) 付 昱 1998.8.17 21:50

E-mail

Fyg@163.net

Unit Notifyicon;

Interface

Uses

Windows, Messages, Sysutils, Classes, Graphics, Controls, Forms,

Dialogs,

DSGnintf, shellapi, extractrls, menus

Const

WM_MY_NOTIFY = WM_USER 100;

Type

TPopupStyle = set of

(Left_Click, Right_Click, Left_DBClick, Right_DbClick);

TWHOBUTTON = (B_LEFT, B_RIGHT);

TMouseEvent =

Procedure (Sender: Tobject; X, Y: Word; Whobutton: twhobutton)

Of Object;

// --------- Class Tnotifyicon ---------

TNOTIFYICON = Class (TCUSTOMCONTROL)

Private

{Private Declarations}

Ficon: ticon; fpda: pNOTIFYICONDATA;

FTITLE: STRING;

Ficonvisible: boolean;

FPOPUPMENU: TPOPUPMENU;

FPOPStyle: TPopupstyle;

FoniconMousedown: tmouseevent;

Fonicondoucast: tmouseevent;

Procedure seticon (icon: ticon);

Procedure setTitle (NewTitle: String);

Function isshowing: bolean;

Procedure Showit (Accept: Boolean);

Procedure NotifyiconClick (var Msg: tMessage);

Message WM_MY_NOTIFY;

protected

{Protected Declarations}

public

{Public declarations}

Property isvisible: Boolean Read Isshowing Write showit;

Constructor Create (Aowner: Tcomponent); OVERRIDE;

PROCEDURE SHOWICON;

PROCEDURE HIDEICON;

DESTRUCTOR DESTROY; OVERRIDE;

Procedure Modifyicon (Newicon: Ticon);

proca;

Published

{Published Declarations}

Property Height Default 33;

Property Width Default 33;

Property Notifyicon: Ticon Read Ficon Write Seticon;

Property Title: String Read Ftitle Write Settitle;

Property Onicondoucast: TMouseevent

Read Fonicondoucast Write FonicondoubleClick;

Property Onicymousedown: TMouseevent

Read foniconMousedown Write FoniconMousedown;

Property Popupmenu: TPopupmenu Read FpopUpMenu Write FpopupMenu;

Property PopupStyle: TPopupStyle Read Fpopupstyle

Write fpopupstyle default [];

END;

PROCEDURE register;

IMPLEMentation

PROCEDURE register;

Begin

Registercomponents ('MyControl', [TNOTIFYICON]);

END;

Procedure TNotifyicon.showit (Accept: Boolean);

Begin

if accept = True Ten Showicon

Else Hideicon;

END;

Procedure tnotifyicon.paint;

Begin

IF (csdesigning in componentstate) THEN

Begin

Width: = 33;

HEIGHT: = 33;

With Canvas Do

Begin

Brush.color: = clinfobk;

Ellipse (0, 0, Self.width, Self.height);

Font.color: = CLBLUE;

Brush.style :=Bsclear;

FLOODFILL (5, 5, Clinfobk, fsborder); brush.color: = clinfobk;

TextOut (3, Self.height Div 2-6, 'Notify');

end

END;

END;

Procedure TNOTICON.NOTIFYICONCLICK (VAR MSG: TMESSAGE);

VAR P: ​​TPOINT;

Begin

Try

Case msg.lparam of

WM_LBUTTONDOWN:

Begin

GetCursorpos (P);

if LEFT_CLICK IN FPOPSTYLE THEN

Begin

SetForegroundWindow (PARENTWINDOW);

FpopupMenu.Popup (P.X, P.Y);

END;

IF assigned (foniconmousedown) THEN

Begin

FoniconMousedown (Self, P.x, P.Y, B_LEFT);

END;

END;

WM_RBUTTONDOWN:

Begin

GetCursorpos (P);

if Right_Click In FpopStyle Then

Begin

SetForegroundWindow (PARENTWINDOW);

FpopupMenu.Popup (P.X, P.Y);

END;

IF assigned (foniconmousedown) THEN

Begin

FoniconMousedown (Self, P.x, P.Y, B_Right);

END;

END;

WM_LBUTTONDBLCLK:

Begin

GetCursorpos (P);

if LEFT_DBCLICK IN FPOPSTYLE THEN

Begin

SetForegroundWindow (PARENTWINDOW);

FpopupMenu.Popup (P.X, P.Y);

END;

IF Assigned (Fonicondoucast) THEN

Begin

FonicondoubleClick (Self, P.x, P.Y, B_LEFT);

END;

END;

WM_RBUTTONDBLCLK:

Begin

GetCursorpos (P);

if Right_Click In FpopStyle Then

Begin

SetForegroundWindow (PARENTWINDOW);

FpopupMenu.Popup (P.X, P.Y);

END;

IF Assigned (Fonicondoucast) THEN

Begin

FonicondoubleClick (Self, P.x, P.Y, B_Right);

END;

END;

END;

Except

END;

END;

Function MakelangId (P, S: Word): cardinal

Begin

Result: = (((s) SHL 10) or (p));

END;

Constructor Tnotifyicon.create (Aowner: Tcomponent);

Begin

Try

Inherited Create (Aowner);

Ficon: = ticon.create;

HEIGHT: = 36;

Width: = 36;

Visible: = false;

Ftitle: = 'Welcome';

FICONVISIBLE: = FALSE;

// ------------- Set TRAY INFO ---------

ParentWindow: = twinControl (aowner) .handle;

NEW (FPDA);

With fpda ^ do

Begin

UcallbackMessage: = WM_MY_NOTIFY; CBSIZE: = SizeOf (fpda ^);

UID: = 200;

WND: = Handle;

UFLAGS: = NIF_ICON NIF_TIP NIF_MESSAGE;

END;

IF (csdesigning in componentstate) THEN

Begin

IF getUserDefaultlcid =

Makelangid (Lang_CHINESE, SUBLANG_CHINESE_SIMPLIFIED) THEN

Application.Messagebox (

'Write by Nanchang University Fuzheng' # 13 # 13'e-mail: fyg@163.net' # 13#13 '

1998.8.17 ',

'TNOTIFYICON Controls V 1.01', MB_ok MB_ICONInInformation)

Else

Application.Messagebox (

'Write by Nanchang University

Fuyugang '# 13 # 13'e-mail: fyg@163.net' # 13#13' 1998.8.17 ',

'TNOTICON Component V 1.01', MB_OK MB_ICONInformation;

END;

Except

ShowMessage ('Tnotifyicon Create Error');

END;

END;

Procedure TNOTICON.SETICON (ICON: TICON);

Begin

Ficon.Assign (icon);

END;

PROCEDURE TNOTIFYICON.SHOWICON;

Begin

Try

IF ficon.handle = 0 THEN

Begin

EXIT;

END;

IF ficon.handle <> fpda ^ .hicon Then

Hideicon;

IF FICONVISIBLE = FALSE THEN

Begin

FPDA ^ .hicon: = ficon.handle;

FICONVISIBLE: = True;

Shell_Notifyicon (NIM_ADD, FPDA);

END;

Except

ShowMessage ('Tnotifyicon Show Error');

END;

END;

PROCEDURE TNOTICON.HIDECION;

Begin

Try

IF ficonvisible kil

Begin

FICONVISIBLE: = FALSE;

Shell_Notifyicon (Nim_Delete, FPDA);

END;

Except

ShowMessage ('Tnotifyicon Hide Error');

END;

END;

Procedure Tnotifyicon.SetTitle (NewTitle: String);

Begin

FTITLE: = NewTitle;

Stropy (fpda ^ .sztip, pchar (ftitle));

IF ficonvisible kil

Begin

Hideicon;

Showicon;

END;

END;

DESTRUCTOR TNOTIFYICON.DESTROY;

Begin

Try

Hideicon;

Dispose (FPDA);

Ficon.free;

Inherited destroy;

Except

ShowMessage ('Tnotifyicon Destroy Error');

END;

Procedure TNotifyicon.Modifyicon (Newicon: Ticon);

Begin

Try

Seticon (Newicon);

FPDA ^ .hicon: = ficon.handle;

IF ficonvisible kil

Shell_Notifyicon (NIM_MODIFY, FPDA);

Except

ShowMessage ('TNOTICON Modify Error');

END;

END;

Function TNotifyicon.isshowing: boolean;

Begin

Result: = FICONVISIBLE;

END;

End.

转载请注明原文地址:https://www.9cbs.com/read-5436.html

New Post(0)