新型SysTray提示

时间:2010-02-27 18:00:10  来源:第二电脑网  作者:第二电脑网

  第二电脑网导读: $10;  NIM_SETVERSION = $00000004;  NOTIFYICON_VERSION = 3;  NIM_SETFOCUS = $00000003;  NIIF_INFO = $00000001;  NIN_BALLOONSHOW = WM_USER + 2;  NIN_BALLOONHIDE = WM_USER + 3;  NIN_BALLOONTIMEOUT = WM_USER + 4;  NIN_BALLOONUSER...
  正文:在Windows2000里面,拨号网络连接之后,或者是收藏夹被折叠的时候,会有一个漫画框式的提示,这个需要IE5以上的支持。
procedure TForm1.AddNewSysTrayIcon;
const
  TRAY_CALLBACK = WM_USER + $7258;
  NIF_INFO = $10;
  NIM_SETVERSION = $00000004;
  NOTIFYICON_VERSION = 3;
  NIM_SETFOCUS = $00000003;
  NIIF_INFO = $00000001;

  NIN_BALLOONSHOW = WM_USER + 2;
  NIN_BALLOONHIDE = WM_USER + 3;
  NIN_BALLOONTIMEOUT = WM_USER + 4;
  NIN_BALLOONUSERCLICK = WM_USER + 5;


type
  PNewNotifyIconData = ^TNewNotifyIconData;

  TDUMMYUNIONNAME = Record
    case Integer of
      0: (uTimeout: UINT);
      1: (uVersion: UINT);
  end;

  TNewNotifyIconData = Record
    cbSize: Dword;
    Wnd: HWND;
    uID: UINT;
    uFlags: UINT;
    uCallbackMessage: UINT;
    hIcon: HICON;
    szTip: array [0..127] of Char;
    dwState: DWORD; ///Version 5.0
    dwStateMask: DWORD; ///Version 5.0
    szInfo: array [0..255] of Char; ///Version 5.0
    DUMMYUNIONNAME: TDUMMYUNIONNAME;
    szInfoTitle: array [0..63] of Char; ///Version 5.0
    dwInfoFlags: DWORD; ///Version 5.0
  end;
var
  TipInfo, TipTitle: string;
  IconData: TNewNotifyIconData;
begin
  IconData.cbSize := sizeof(IconData);
  IconData.Wnd := Handle;
  IconData.uID := 0;
  IconData.uFlags := NIF_ICON or NIF_MESSAGE or NIF_INFO or NIF_TIP;
  IconData.uCallbackMessage := TRAY_CALLBACK;
  IconData.hIcon := Image1.Picture.Icon.Handle;  ///an icon's handle
  IconData.szTip := 'That''s all.';
  TipInfo := 'Please send me email.';
  strPLCopy(IconData.szInfo, TipInfo, sizeof(IconData.szInfo) - 1);
  IconData.DUMMYUNIONNAME.uTimeout := 3000;
  TipTitle := 'Happyjoe@21cn.com';
  strPLCopy(IconData.szInfoTitle, TipTitle, sizeof(IconData.szInfoTitle) - 1);
  IconData.dwInfoFlags := NIIF_INFO;
  if not Shell_NotifyIcon(NIM_ADD, @IconData) then
    showmessage('add fail');
  IconData.DUMMYUNIONNAME.uVersion := NOTIFYICON_VERSION;
  if not Shell_NotifyIcon(NIM_SETVERSION, @IconData) then
    showmessage('setversion fail');
end;
**************
首先定义新的常数:
const
  NIF_INFO = $10;
  NIM_SETVERSION = $00000004;
  NOTIFYICON_VERSION = 3;
  NIM_SETFOCUS = $00000003;
  NIIF_INFO = $00000001;
  NIIF_WARNING = $00000002;
  NIIF_ERROR = $00000003;

  NIN_BALLOONSHOW = WM_USER + 2;
  NIN_BALLOONHIDE = WM_USER + 3;
  NIN_BALLOONTIMEOUT = WM_USER + 4;
  NIN_BALLOONUSERCLICK = WM_USER + 5;
  NIN_SELECT = WM_USER + 0;
  NINF_KEY = $1;
  NIN_KEYSELECT = NIN_SELECT or NINF_KEY;
  {上面列的可能不全,如果没有定义到的,可在 vs.net 中 vc7 中的 PlatformSDKIncludeShellAPI.h 中找到}

再定义一个SysTrayIcon的回传消息:
  TRAY_CALLBACK = WM_USER + $7258;

然后定义新的 NotifyIconData 结构(放在Type中):
Type
  PNewNotifyIconData = ^TNewNotifyIconData;

"新型SysTray提示"由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Language/Delphi/12945.html


关键字:

关于《新型SysTray提示》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td