public { Public declarations } procedure IconTray(var Msg:TMessage);message wm_rbuttondown;
其次就需要在该窗体的implementation部分定义该消息处理函数的具体实现过程: procedure TForm1.IconTray(var Msg: TMessage); var Pt: TPoint; I : Byte; begin case Msg.LParam of //根据Lparam分量的值确定消息种类 wm_rbuttondown: //若用户用鼠标右击指示图标,则弹出一个快捷菜单 begin GetCursorPos(Pt); //获取光标位置 SetForegroundWindow(Handle); //将窗口放至顶层 PopupMenu1.Popup(Pt.x,Pt.y); //弹出快捷菜单 end; wm_lbuttondblclk: //若用户用鼠标左键双击指示图标,则弹出应用程序窗口 begin ShowWindow(Handle,SW_Restore); //显示应用程序主窗口 SetForegroundWindow(Handle); //显示主窗口上所有控件 For I :=0 to componentcount-1 do if Components[I] is TWinControl then ShowWindow(TWinControl(Components[I]).Handle,SW_Normal); end; end;