var
Busy: Boolean = false;
procedure TForm1.OnIconNotify(var Message: TMessage);
var
Mousepos: TPoint;
begin
if not Busy then
begin
Busy := true;
if Message.LParam=WM_LBUTTONDBLCLK then
form1.Visible := true;
end;
if Message.LParam = WM_RBUTTONDBLCLK then
begin
Mousepos := mouse.CursorPos;
popupmenu1.Popup(mousepos.X,mousepos.Y);
end;
Busy := false;
end;
nid.szTip := 'This is a test application'; // 提示字符串
nid.uCallbackMessage := MY_MESSAGE; // 回调函数消息
nid.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE; // 指明哪些字段有?
if not Shell_NotifyIcon(NIM_ADD, @nid) then begin
ShowMessage('Failed!');
Application.Terminate;
end;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
nid: TNotifyIconData;
begin
nid.cbSize := sizeof(nid); // nid变量的字节数
nid.uID := 0; //内部标识,与加入小图标时的数一致
nid.Wnd := Handle; //主窗口句柄
Shell_NotifyIcon(NIM_DELETE, @nid); //去掉小图标
end;
procedure TForm1.Min(var Message: TMessage);
begin
if message.WParam = SC_MINIMIZE then
begin
form1.Visible := false;
ShowWindow(application.Handle,sw_Hide);
end
else if message.WParam = $F012 then
begin
end
else
Inherited;
end;
procedure TForm1.exit1Click(Sender: TObject);
begin
close;
end;
procedure TForm1.about1Click(Sender: TObject);
begin
form1.Visible := true;
ShowWindow(application.Handle,sw_show);
end;
procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
Mousepos: TPoint;
begin
if button = mbright then
begin
Mousepos := mouse.CursorPos;
popupmenu1.Popup(mousepos.X,mousepos.Y);
end;
end;
//托盘消息处理事件
//------------------------------------------------------------------
procedure TMainForm.CDRomTrayMessage(var message: Tmessage);
var
CursorPos : TPoint;
begin
//在这里处理用户点击托盘图标事件,可以根据WM_MOUSEMOVE消息的不同情况产生不同的
//回应,例如区别对待单击和双击等等
case message.lParam of
//
//WM_LBUTTONDOWN :
//mcisendstring( pchar(cdromStatus),nil,0,handle);
//if not Busy then begin