📄 ntray.htm
字号:
<html>
<head>
<title></title>
</head>
<body>
<p align="left"><font color="#000000" face="Verdana" size="6"><strong>CTrayNotifyIcon</strong></font></p>
<p><font color="#000000" face="Arial" size="3">Welcome to CTrayNotifyIcon, A freeware MFC
class to encapsulate the tray notification API in 95,98 and NT 4.</font></p>
<p> </p>
<table>
<TBODY>
<tr>
<td><font face="Arial"><a href="#Features">Features</a></font></td>
</tr>
<tr>
<td><font face="Arial"><a href="#History">History</a></font></td>
</tr>
<tr>
<td><font face="Arial"><a href="#APIReference">API Reference</a></font></td>
</tr>
<tr>
<td><font face="Arial"><a href="#Contact">Contacting the Author</a></font></td>
</tr>
</TBODY>
</table>
<p> </p>
<p> </p>
<p> </p>
<p><font face="Arial"><a name="Features"></a><big><strong><big>Features</big></strong></big>
</font>
<ul>
<li><font color="#000000" face="Arial" size="3">Simple and clean C++ interface.</font> </li>
<li><font color="#000000" face="Arial" size="3">The classes are fully Unicode compliant and
include Unicode built options in the workspace file.</font> </li>
<li><font face="Arial">All code compiles cleanly at warning level 4</font></li>
</ul>
<p> </p>
<p> </p>
<p> </p>
<p><font face="Arial"><big><a name="History"></a></big><font color="#000000" size="5"><strong>History</strong></font></font></p>
<p><font color="#000000" face="Arial" size="3"><strong>V1.3 (22 July 1998)</strong></font>
<ul>
<li><font face="Arial">Code now compiles cleanly at warning level 4</font></li>
<li><font face="Arial">Code is now UNICODE enabled + build configurations are provided</font></li>
<li><font face="Arial">The documentation for the class has been completely revamped</font></li>
</ul>
<p><strong><font face="Arial">v1.2 (23 June 1998)</font></strong>
<ul>
<li><font face="Arial">Class now supports the new Taskbar Creation Notification message
which comes with IE 4. This allows the tray icon to be recreated whenever the explorer
restarts (Crashes!!)</font></li>
</ul>
<p><strong><font face="Arial">v1.1 (25 November 1997)</font></strong>
<ul>
<li><font face="Arial">Addition of HideIcon(), ShowIcon() & MoveToExtremeRight </font></li>
<li><font face="Arial">Support for animated tray icons</font></li>
</ul>
<p><strong><font face="Arial">v1.0 (14 May 1997)</font></strong>
<ul>
<li><font face="Arial">Initial Public release.</font></li>
</ul>
<p> </p>
<p> </p>
<p> </p>
<p class="crt"><font face="Arial"><a name="APIReference"></a><big><big><strong>API
Reference</strong></big></big></font></p>
<p><font color="#000000" face="Arial" size="3">Instantiate a CTrayNotifyIcon where it will
be around for the lifetime of your icon. The sample program does this in the mainframe as
the icon will be available for the lifetime of the application. In the sample program this
is done in the mainframe class. The API consists of the the following public functions of
the class CTrayNotifyIcon</font></p>
<p> </p>
<p><font face="Arial"><a href="#CTrayNotifyIcon">CTrayNotifyIcon::CTrayNotifyIcon</a><br>
<a href="#~CTrayNotifyIcon">CTrayNotifyIcon::~CTrayNotifyIcon</a><br>
<a href="#Create">CTrayNotifyIcon::Create</a><br>
<a href="#SetTooltipText">CTrayNotifyIcon::SetTooltipText</a><br>
<a href="#GetTooltipText">CTrayNotifyIcon::GetTooltipText</a><br>
<a href="#SetIcon">CTrayNotifyIcon::SetIcon</a><br>
<a href="#SetStandardIcon">CTrayNotifyIcon::SetStandardIcon</a><br>
<a href="#GetIcon">CTrayNotifyIcon::GetIcon</a><br>
<a href="#UsingAnimatedIcon">CTrayNotifyIcon::UsingAnimatedIcon</a><br>
<a href="#SetNotificationWnd">CTrayNotifyIcon::SetNotificationWnd</a><br>
<a href="#GetNotificationWnd">CTrayNotifyIcon::GetNotificationWnd</a><br>
<a href="#HideIcon">CTrayNotifyIcon::HideIcon</a><br>
<a href="#SetIcon">CTrayNotifyIcon::ShowIcon</a><br>
<a href="#RemoveIcon">CTrayNotifyIcon::RemoveIcon</a><br>
<a href="#MoveToExtremeRight">CTrayNotifyIcon::MoveToExtremeRight</a><br>
<a href="#OnTrayNotification">CTrayNotifyIcon::OnTrayNotification</a><br>
<a href="#IsShowing">CTrayNotifyIcon::IsShowing</a><br>
<a href="#IsHidden">CTrayNotifyIcon::IsHidden</a></font></p>
<p> </p>
<p><a name="CTrayNotifyIcon"></a><big><strong><font face="Arial">CTrayNotifyIcon::CTrayNotifyIcon</font></strong></big></p>
<p><font face="Arial"><strong>CTrayNotifyIcon::CTrayNotifyIcon();</strong></font></p>
<p><font face="Arial"><strong>Remarks</strong></font></p>
<p><font face="Arial">Standard constructor, just initialises all member variables to safe
values.</font></p>
<p> </p>
<p><a name="~CTrayNotifyIcon"></a><big><strong><font face="Arial">CTrayNotifyIcon::~CTrayNotifyIcon</font></strong></big></p>
<p><font face="Arial"><strong>CTrayNotifyIcon::~CTrayNotifyIcon();</strong></font></p>
<p><font face="Arial"><strong>Remarks</strong></font></p>
<p><font face="Arial">Standard destructor. Internally this will call RemoveIcon to remove
the icon from the UI.</font></p>
<p> </p>
<p><a name="Create"></a><big><strong><font face="Arial">CTrayNotifyIcon::Create</font></strong></big></p>
<p><font face="Arial"><strong>BOOL CTrayNotifyIcon::Create(CWnd* pNotifyWnd, UINT nID,
LPCTSTR pszTooltipText, HICON hIcon, UINT nNotifyMessage);</strong></font></p>
<p><font face="Arial"><strong>BOOL CTrayNotifyIcon::Create(CWnd* pNotifyWnd, UINT uID,
LPCTSTR pszTooltipText, HICON* phIcons, int nNumIcons, DWORD dwDelay, UINT
nNotifyMessage);</strong></font></p>
<p><strong><font face="Arial">Return Value</font></strong></p>
<p class="t"><font face="Arial">TRUE if the tray icon was successfully created otherwise
FALSE.</font></p>
<p><font face="Arial"><strong>Parameters</strong></font></p>
<p><font color="#000000" face="Arial" size="3"><em>pNotifyWnd</em>: The window to send
notification messages to. This can be changed later by using the SetNotificationWnd
method.</font></p>
<p><font color="#000000" face="Arial" size="3"><em>uID</em>: An application defined value
to associate with each tray icon. This allows you to display multiple icons from one app.
CTrayNotifyIcon also overrides its meaning such that it is used as the menu resource id
for the context menu.</font></p>
<p><font color="#000000" face="Arial" size="3"><em>pszTooltipText</em>: Initial tooltip
text to display. This can be changed later using the SetTooltipText method.</font></p>
<p><font color="#000000" face="Arial" size="3"><em>hIcon</em>: The icon to display. This
can be changed later using the SetIcon method.</font></p>
<p><font color="#000000" face="Arial" size="3"><em>nNotifyMessage</em>: This is the
notification message to use to inform the window about mouse messages. This should be
defined as some WM_USER message and handled in the notification windows message map using
the ON_MESSAGE macro. To see how to hook this up have a look at the mainfrm.cpp</font></p>
<p><font color="#000000" face="Arial" size="3"><em>phIcons</em>: pointer to an array of
icon handles to use to do the icon animation.</font></p>
<p><font color="#000000" face="Arial" size="3"><em>nNumIcons</em>: The number of icons
phIcons points to.</font></p>
<p><font color="#000000" face="Arial" size="3"><em>dwDelay</em>: interval in milliseconds
between icon animation frames.</font></p>
<p><font face="Arial"><strong>Remarks</strong></font></p>
<p><font face="Arial">Creates a tray notification icon.</font></p>
<p> </p>
<p><a name="SetTooltipText"></a><big><strong><font face="Arial">CTrayNotifyIcon::SetTooltipText</font></strong></big></p>
<p><font face="Arial"><strong>BOOL CTrayNotifyIcon::SetTooltipText(LPCTSTR
pszTooltipText);</strong></font></p>
<p><font face="Arial"><strong>BOOL CTrayNotifyIcon::SetTooltipText(UINT nID);</strong></font></p>
<p><strong><font face="Arial">Return Value</font></strong></p>
<p><font face="Arial">TRUE if the tooltip text was changed successfully otherwise FALSE</font></p>
<p><font face="Arial"><strong>Parameters</strong></font></p>
<p><font face="Arial"><em>pszTooltipText</em> The text to set</font></p>
<p><font face="Arial"><em>nID</em> A windows string resource ID of the text to set</font></p>
<p><font face="Arial"><strong>Remarks</strong></font></p>
<p><font face="Arial">Sets the tooltip text associated with the tray icon</font></p>
<p> </p>
<p><a name="GetTooltipText"></a><big><strong><font face="Arial">CTrayNotifyIcon::GetTooltipText</font></strong></big></p>
<p><font face="Arial"><strong>CString CTrayNotifyIcon::GetTooltipText() const</strong></font></p>
<p><strong><font face="Arial">Return Value</font></strong></p>
<p><font face="Arial">The current tooltip text </font></p>
<p> </p>
<p><a name="SetIcon"></a><big><strong><font face="Arial">CTrayNotifyIcon::SetIcon</font></strong></big></p>
<p><strong><font face="Arial">BOOL SetIcon(HICON hIcon);</font></strong></p>
<p><strong><font face="Arial">BOOL SetIcon(LPCTSTR lpIconName);</font></strong></p>
<p><font face="Arial"><strong>BOOL SetIcon(UINT nIDResource);</strong></font></p>
<p><font face="Arial"><strong>BOOL SetIcon(HICON* phIcons, int nNumIcons, DWORD dwDelay);</strong></font></p>
<p><font face="Arial"><strong>Return Value</strong></font></p>
<p><font face="Arial">TRUE if the icon was changed successfully otherwise FALSE</font></p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -