一个托盘的问题(50分)

  • 主题发起人 主题发起人 润五月
  • 开始时间 开始时间

润五月

Unregistered / Unconfirmed
GUEST, unregistred user!
我做了个托盘程序,每次都是能缩小到托盘中,但是怎么点都出不来了,不只是为什么?谁能帮帮我!
或者给我个小程序看看,谢谢
 
这个问题讨论多次。
 
unit Ri;

interface

uses
; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
; Menus,shellapi;

const
; WM_TRAYNOTIFY=2000;
; MY_TRAY_ICON=1000;
;
type
; TGuoRiJian = class(TForm)
; ; PopupMenu1: TPopupMenu;
; ; N2: TMenuItem;
; ; procedure FormCreate(Sender: TObject);
; ; procedure FormClose(Sender: TObject; var Action: TCloseAction);
; ; procedure FormDestroy(Sender: TObject);
; ; procedure N2Click(Sender: TObject);
; private
; ; { Private declarations }
; public
; ; { Public declarations }
; ; procedure OnMin(Sender: TObject);
; ; procedure WMTrayNotify(var Msg : TMessage);Message WM_TRAYNOTIFY;
; end;

var
; GuoRiJian: TGuoRiJian;
; nid:TNOTIFYICONDATA;

implementation

{$R *.DFM}

procedure TGuoRiJian.FormCreate(Sender: TObject);
begin
; Application.OnMinimize:=OnMin;
end;

procedure TGuoRiJian.OnMin(Sender: TObject);
begin
; nid.cbSize:=Sizeof(TNOTIFYICONDATA);
; nid.Wnd:=Handle;
; nid.uID:=MY_TRAY_ICON;
; nid.uFlags:=NIF_TIP OR NIF_ICON OR NIF_MESSAGE;
; nid.hIcon:=Application.Icon.Handle;
; nid.szTip:='我的程序';
; nid.uCallbackMessage:=WM_TRAYNOTIFY;
; Shell_NotifyIcon(NIM_ADD,@nid);
; ShowWindow(Application.Handle,SW_HIDE);
end;

procedure TGuoRiJian.WMTrayNotify(var Msg: TMessage);
var
; p:TPoint;
begin
; if Msg.LParam=WM_LBUTTONDBLCLK then
; begin
; ; nid.cbSize:=Sizeof(TNOTIFYICONDATA);
; ; nid.Wnd:=Application.Handle;
; ; nid.uID:=MY_TRAY_ICON;
; ; nid.uFlags:=NIF_TIP OR NIF_ICON OR NIF_MESSAGE;
; ; nid.uCallbackMessage:=WM_TRAYNOTIFY;
; ; nid.szTip:='';
; ; Shell_NotifyIcon(NIM_ADD,@nid);
; ; ShowWindow(Application.Handle,SW_SHOW);
; ; Application.Restore;
; end
; ; else if Msg.LParam=WM_RBUTTONUP then
; ; begin
; ; ; GetCursorpos(p);
; ; ; PopupMenu1.Popup (p.x,p.y);
; ; end;
end;

procedure TGuoRiJian.FormDestroy(Sender: TObject);
begin
; Shell_NotifyIcon(NIM_DELETE,@nid);
end;

procedure TGuoRiJian.N2Click(Sender: TObject);
begin
; Close;
end;

end.
 
同意 gotosea
顺便问一句,gotosea 是不是 ;MM
QQ:36521339
 
去http://antic_ant.delphibbs.com
有源码下载
readtoolssource.zip
 
多人接受答案了。
 
unit Ri;

interface

uses
; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
; Menus,shellapi;

const
; WM_TRAYNOTIFY=2000;
; MY_TRAY_ICON=1000;
;
type
; TGuoRiJian = class(TForm)
; ; PopupMenu1: TPopupMenu;
; ; N2: TMenuItem;
; ; procedure FormCreate(Sender: TObject);
; ; procedure FormClose(Sender: TObject; var Action: TCloseAction);
; ; procedure FormDestroy(Sender: TObject);
; ; procedure N2Click(Sender: TObject);
; private
; ; { Private declarations }
; public
; ; { Public declarations }
; ; procedure OnMin(Sender: TObject);
; ; procedure WMTrayNotify(var Msg : TMessage);Message WM_TRAYNOTIFY;
; end;

var
; GuoRiJian: TGuoRiJian;
; nid:TNOTIFYICONDATA;

implementation

{$R *.DFM}

procedure TGuoRiJian.FormCreate(Sender: TObject);
begin
; Application.OnMinimize:=OnMin;
end;

procedure TGuoRiJian.OnMin(Sender: TObject);
begin
; nid.cbSize:=Sizeof(TNOTIFYICONDATA);
; nid.Wnd:=Handle;
; nid.uID:=MY_TRAY_ICON;
; nid.uFlags:=NIF_TIP OR NIF_ICON OR NIF_MESSAGE;
; nid.hIcon:=Application.Icon.Handle;
; nid.szTip:='我的程序';
; nid.uCallbackMessage:=WM_TRAYNOTIFY;
; Shell_NotifyIcon(NIM_ADD,@nid);
; ShowWindow(Application.Handle,SW_HIDE);
end;

procedure TGuoRiJian.WMTrayNotify(var Msg: TMessage);
var
; p:TPoint;
begin
; if Msg.LParam=WM_LBUTTONDBLCLK then
; begin
; ; nid.cbSize:=Sizeof(TNOTIFYICONDATA);
; ; nid.Wnd:=Application.Handle;
; ; nid.uID:=MY_TRAY_ICON;
; ; nid.uFlags:=NIF_TIP OR NIF_ICON OR NIF_MESSAGE;
; ; nid.uCallbackMessage:=WM_TRAYNOTIFY;
; ; nid.szTip:='';
; ; Shell_NotifyIcon(NIM_MODIFY,@nid);
; ; ShowWindow(Application.Handle,SW_SHOW);
; ; Application.Restore;
; end
; ; else if Msg.LParam=WM_RBUTTONUP then
; ; begin
; ; ; GetCursorpos(p);
; ; ; PopupMenu1.Popup (p.x,p.y);
; ; end;
end;

procedure TGuoRiJian.FormDestroy(Sender: TObject);
begin
; Shell_NotifyIcon(NIM_DELETE,@nid);
end;

procedure TGuoRiJian.N2Click(Sender: TObject);
begin
; Close;
end;

end.
 
后退
顶部