读书人

为什么小弟我的状态区图标处理不了鼠标

发布时间: 2012-03-05 11:54:01 作者: rapoo

为什么我的状态区图标处理不了鼠标消息?
图标成功载入状态区,可是无论是双击还是单击图标,程序都没有执行相应的操作,不知道是为什么,代码如下,请各位帮忙看看:
const
CM_RESTORE=WM_USER+$1000; //自定义”恢复“消息
GDJT_APP_NAME='GDJT_Sysytem';
const
ID_MAIN=100;
WM_GDJTNOTIFY=WM_USER+100;
strNotifyTip='轨道交通资料管理服务器';//状态区的提示消息
//定义的图标ID;

//恢复消息
procedure TServerForm.RestoreRequest(var message:TMessage);
begin
if IsIconic(Application.Handle)=true then
Application.Restore //恢复窗体
else
Application.BringToFront;
end;

//在状态区添加图标
function TServerForm.AddIcon(hwnd:HWND):boolean;
begin
nid.cbSize:=sizeof(NOTIFYICONDATA);
nid.Wnd:=hwnd;
nid.uID:=ID_MAIN;
nid.uFlags:=NIF_MESSAGE or NIF_ICON or NIF_TIP; //这里已经重新设置了有效参数了
nid.hIcon:=LoadICON(hInstance,'MAINICON');
strCopy(nid.szTip,strNotifyTip);
AddIcon:=Shell_NotifyIcon(NIM_ADD,@nid);
end;

//从状态区移去图标
function TServerForm.RemoveIcon(hwnd:HWND):boolean;
var
nid:NOTIFYICONDATA;
begin
nid.cbSize:=Sizeof(NOTIFYICONDATA);
nid.Wnd:=hwnd;
nid.uID:=ID_MAIN;
nid.uFlags:=0;
RemoveICON:=Shell_NotifyIcon(NIM_DELETE,@nid);
end;

//自定义消息处理函数-无论怎么点击,程序就是没有反应
procedure TServerForm.Notify(var msg:TMessage);
var
pt:TPoint;
begin
case msg.LParam of
WM_RBUTTONDOWN: //当点击右键时,弹出快捷菜单
begin
SetForeGroundWindow(nid.wnd);
GetCursorPos(Pt);
Popupmenu.Popup(pt.x, pt.y);
end;
WM_LBUTTONDOWN: //左键按下,窗体置前
Application.MainForm.BringToFront;
WM_LBUTTONDBLCLK: //左键双击时
SetForegroundWindow(Application.Handle);
end;
end;

[解决办法]
怎么还不给分啊!!

读书人网 >.NET

热点推荐