如何在控件里截获调用程序的消息? 应该会有的。1.确认你在Application.OnMessage的处理事件里定义了对自定义消息的处理2.确认你确实发送了自定义消息3.检查你的程序 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个问题,你不会设置了form的属性吧 这是我的代码..........改用APPLICATION.OnMessage 还是不行,用WndProc加不进去unit Systray;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;type PNotifyIconDataA = ^TNotifyIconDataA; PNotifyIconDataW = ^TNotifyIconDataW; PNotifyIconData = PNotifyIconDataA; {$EXTERNALSYM _NOTIFYICONDATAA} _NOTIFYICONDATAA = record cbSize: DWORD; Wnd: HWND; uID: UINT; uFlags: UINT; uCallbackMessage: UINT; hIcon: HICON; szTip: array [0..63] of AnsiChar; end; {$EXTERNALSYM _NOTIFYICONDATAW} _NOTIFYICONDATAW = record cbSize: DWORD; Wnd: HWND; uID: UINT; uFlags: UINT; uCallbackMessage: UINT; hIcon: HICON; szTip: array [0..63] of WideChar; end; {$EXTERNALSYM _NOTIFYICONDATA} _NOTIFYICONDATA = _NOTIFYICONDATAA; TNotifyIconDataA = _NOTIFYICONDATAA; TNotifyIconDataW = _NOTIFYICONDATAW; TNotifyIconData = TNotifyIconDataA; {$EXTERNALSYM NOTIFYICONDATAA} NOTIFYICONDATAA = _NOTIFYICONDATAA; {$EXTERNALSYM NOTIFYICONDATAW} NOTIFYICONDATAW = _NOTIFYICONDATAW; {$EXTERNALSYM NOTIFYICONDATA} NOTIFYICONDATA = NOTIFYICONDATAA;const {$EXTERNALSYM NIM_ADD} NIM_ADD = $00000000; {$EXTERNALSYM NIM_MODIFY} NIM_MODIFY = $00000001; {$EXTERNALSYM NIM_DELETE} NIM_DELETE = $00000002; {$EXTERNALSYM NIF_MESSAGE} NIF_MESSAGE = $00000001; {$EXTERNALSYM NIF_ICON} NIF_ICON = $00000002; {$EXTERNALSYM NIF_TIP} NIF_TIP = $00000004;{$EXTERNALSYM Shell_NotifyIconA}function Shell_NotifyIconA(dwMessage: DWORD; lpData: PNotifyIconDataA): BOOL; stdcall;external 'shell32.dll';{$EXTERNALSYM Shell_NotifyIconW}function Shell_NotifyIconW(dwMessage: DWORD; lpData: PNotifyIconDataW): BOOL; stdcall;external 'shell32.dll';{$EXTERNALSYM Shell_NotifyIcon}function Shell_NotifyIcon(dwMessage: DWORD; lpData: PNotifyIconData): BOOL; stdcall;external 'shell32.dll';CONSTWM_SystrayMessage=WM_USER+1000;Systray_MouseLDown=513;Systray_MouseRDown=516;Systray_MouseLUp=514;Systray_MouseRUp=517;Systray_MouseLDbl=516;Systray_MouseRDbl=518;type TSystray = class(TComponent) private FSystrayInfo:TNOTIFYICONDATA; FSystrayMouseMoveEvent:TNotifyEvent;//procedure (Sender: TObject) of object; FSystrayMouseLDownEvent:TNotifyEvent; FSystrayMouseRDownEvent:TNotifyEvent; FSystrayMouseLUpEvent:TNotifyEvent; FSystrayMouseRUpEvent:TNotifyEvent; FSystrayMouseLDblEvent:TNotifyEvent; FSystrayMouseRDblEvent:TNotifyEvent; FSystrayMouseLClickEvent:TNotifyEvent; FSystrayMouseRClickEvent:TNotifyEvent; PROCEDURE MessageProc(Var Msg:TMsg;var Handled: Boolean); { Private declarations } protected { Protected declarations } public Procedure SystrayADDIcon(SICON:TNOTIFYICONDATA); Procedure SystrayDelIcon(SICON:PNOTIFYICONDATA); Procedure SystrayModIcon(SICON:PNOTIFYICONDATA); { Public declarations } published property SystrayInfo:TNOTIFYICONDATA read FSystrayInfo write SystrayADDIcon; property OnMouseMove:TNotifyEvent read FSystrayMouseMoveEvent write FSystrayMouseMoveEvent; property OnMouseLDOWN:TNotifyEvent read FSystrayMouseLDownEvent write FSystrayMouseLDownEvent; property OnMouseRDOWN:TNotifyEvent read FSystrayMouseRDownEvent write FSystrayMouseRDownEvent; property OnMouseLUP:TNotifyEvent read FSystrayMouseLUpEvent write FSystrayMouseLUpEvent; property OnMouseRUP:TNotifyEvent read FSystrayMouseRUpEvent write FSystrayMouseRUpEvent; property OnDblLClicK:TNotifyEvent read FSystrayMouseLDblEvent write FSystrayMouseLDblEvent; property OnDblRClick:TNotifyEvent read FSystrayMouseRDblEvent write FSystrayMouseRDblEvent; property OnLClick:TNotifyEvent read FSystrayMouseLClickEvent write FSystrayMouseLClickEvent; property OnRClick:TNotifyEvent read FSystrayMouseRClickEvent write FSystrayMouseRClickEvent; { Published declarations } end;procedure Register;implementationProcedure TSystray.MessageProc(Var Msg:TMessage)Message WM_SystrayMessag;beginIF msg.WParam=7 thenCase Msg.LParam of512:if Assigned(FSystrayMouseMoveEvent) then FSystrayMouseMoveEvent(self);513:if Assigned(FSystrayMouseLDownEvent) then FSystrayMouseLDownEvent(self);514:if Assigned(FSystrayMouseLUpEvent) thenbeginFSystrayMouseLUpEvent(self);if Assigned(FSystrayMouseLClickEvent) then FSystrayMouseLClickEvent(self);end;515:if Assigned(FSystrayMouseLDblEvent) then FSystrayMouseLDblEvent(self);516:if Assigned(FSystrayMouseRDownEvent) then FSystrayMouseRDownEvent(self);517:if Assigned(FSystrayMouseRUpEvent) thenbeginFSystrayMouseRUpEvent(self);if Assigned(FSystrayMouseRClickEvent) then FSystrayMouseRClickEvent(self);end;518:if Assigned(FSystrayMouseRDblEvent) then FSystrayMouseRDblEvent(self);end;inherited;end;Procedure TSystray.SystrayADDIcon(SICON:TNOTIFYICONDATA);beginSICON.uCallbackMessage:=WM_SystrayMessage;SICON.uFlags:=SICON.uFlags or NIF_MESSAGE;SICON.cbSize:=Sizeof(SICON);application.OnMessage:=MessageProc;If Not Shell_NotifyIcon(NIM_ADD,@SICON) thenShowMessage('系统图标添加错误');end;Procedure TSystray.SystrayDelIcon(SICON:PNOTIFYICONDATA);beginSICON^.uCallbackMessage:=WM_SystrayMessage;SICON^.uFlags:=SICON.uFlags or NIF_MESSAGE;SICON^.cbSize:=Sizeof(SICON);If Not Shell_NotifyIcon(NIM_DELETE,SICON) thenShowMessage('系统图标删除错误');end;Procedure TSystray.SystrayModIcon(SICON:PNOTIFYICONDATA);beginSICON^.uCallbackMessage:=WM_SystrayMessage;SICON^.uFlags:=SICON.uFlags or NIF_MESSAGE;SICON^.cbSize:=Sizeof(SICON);If Not Shell_NotifyIcon(NIM_MODIFY,SICON) thenShowMessage('系统图标修改错误');end;procedure Register;begin RegisterComponents('Win32', [TSystray]);end;end. 你的http://www.csdn.net/expert/topic/713/713598.xml?temp=.243725帖子没有必要。我已经删除。 怎么在drawgrid中写文字? 盗QQ2004奥运特别版的木马搞出来了, 现在公布源代码 如何用程序来判断一台电脑上是不是安装了Acrobat reader这个阅读工具? 受朋友所托。500分求助一画图小程序!!! 对《分析DFM文件生成程序界面》提出的问题 如何判断数据库中表或视图是否存在? 请教关于Pascal转成C/C++的问题. 利用delphi采集图像问题! 为什么一直说没法找到project.exe? 一个入门级问题 xml------数据库-----100分 怎样去掉子窗体的标题栏?就像一般窗体border设为为None那样。谢谢
改用APPLICATION.OnMessage 还是不行,用WndProc加不进去
unit Systray;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
PNotifyIconDataA = ^TNotifyIconDataA;
PNotifyIconDataW = ^TNotifyIconDataW;
PNotifyIconData = PNotifyIconDataA;
{$EXTERNALSYM _NOTIFYICONDATAA}
_NOTIFYICONDATAA = record
cbSize: DWORD;
Wnd: HWND;
uID: UINT;
uFlags: UINT;
uCallbackMessage: UINT;
hIcon: HICON;
szTip: array [0..63] of AnsiChar;
end;
{$EXTERNALSYM _NOTIFYICONDATAW}
_NOTIFYICONDATAW = record
cbSize: DWORD;
Wnd: HWND;
uID: UINT;
uFlags: UINT;
uCallbackMessage: UINT;
hIcon: HICON;
szTip: array [0..63] of WideChar;
end;
{$EXTERNALSYM _NOTIFYICONDATA}
_NOTIFYICONDATA = _NOTIFYICONDATAA;
TNotifyIconDataA = _NOTIFYICONDATAA;
TNotifyIconDataW = _NOTIFYICONDATAW;
TNotifyIconData = TNotifyIconDataA;
{$EXTERNALSYM NOTIFYICONDATAA}
NOTIFYICONDATAA = _NOTIFYICONDATAA;
{$EXTERNALSYM NOTIFYICONDATAW}
NOTIFYICONDATAW = _NOTIFYICONDATAW;
{$EXTERNALSYM NOTIFYICONDATA}
NOTIFYICONDATA = NOTIFYICONDATAA;const
{$EXTERNALSYM NIM_ADD}
NIM_ADD = $00000000;
{$EXTERNALSYM NIM_MODIFY}
NIM_MODIFY = $00000001;
{$EXTERNALSYM NIM_DELETE}
NIM_DELETE = $00000002; {$EXTERNALSYM NIF_MESSAGE}
NIF_MESSAGE = $00000001;
{$EXTERNALSYM NIF_ICON}
NIF_ICON = $00000002;
{$EXTERNALSYM NIF_TIP}
NIF_TIP = $00000004;{$EXTERNALSYM Shell_NotifyIconA}
function Shell_NotifyIconA(dwMessage: DWORD; lpData: PNotifyIconDataA): BOOL; stdcall;external 'shell32.dll';
{$EXTERNALSYM Shell_NotifyIconW}
function Shell_NotifyIconW(dwMessage: DWORD; lpData: PNotifyIconDataW): BOOL; stdcall;external 'shell32.dll';
{$EXTERNALSYM Shell_NotifyIcon}
function Shell_NotifyIcon(dwMessage: DWORD; lpData: PNotifyIconData): BOOL; stdcall;external 'shell32.dll';
CONST
WM_SystrayMessage=WM_USER+1000;
Systray_MouseLDown=513;
Systray_MouseRDown=516;
Systray_MouseLUp=514;
Systray_MouseRUp=517;
Systray_MouseLDbl=516;
Systray_MouseRDbl=518;
type
TSystray = class(TComponent)
private
FSystrayInfo:TNOTIFYICONDATA;
FSystrayMouseMoveEvent:TNotifyEvent;//procedure (Sender: TObject) of object;
FSystrayMouseLDownEvent:TNotifyEvent;
FSystrayMouseRDownEvent:TNotifyEvent;
FSystrayMouseLUpEvent:TNotifyEvent;
FSystrayMouseRUpEvent:TNotifyEvent;
FSystrayMouseLDblEvent:TNotifyEvent;
FSystrayMouseRDblEvent:TNotifyEvent;
FSystrayMouseLClickEvent:TNotifyEvent;
FSystrayMouseRClickEvent:TNotifyEvent;
PROCEDURE MessageProc(Var Msg:TMsg;var Handled: Boolean);
{ Private declarations }
protected
{ Protected declarations }
public Procedure SystrayADDIcon(SICON:TNOTIFYICONDATA);
Procedure SystrayDelIcon(SICON:PNOTIFYICONDATA);
Procedure SystrayModIcon(SICON:PNOTIFYICONDATA);
{ Public declarations }
published
property SystrayInfo:TNOTIFYICONDATA read FSystrayInfo write SystrayADDIcon;
property OnMouseMove:TNotifyEvent read FSystrayMouseMoveEvent write FSystrayMouseMoveEvent;
property OnMouseLDOWN:TNotifyEvent read FSystrayMouseLDownEvent write FSystrayMouseLDownEvent;
property OnMouseRDOWN:TNotifyEvent read FSystrayMouseRDownEvent write FSystrayMouseRDownEvent;
property OnMouseLUP:TNotifyEvent read FSystrayMouseLUpEvent write FSystrayMouseLUpEvent;
property OnMouseRUP:TNotifyEvent read FSystrayMouseRUpEvent write FSystrayMouseRUpEvent;
property OnDblLClicK:TNotifyEvent read FSystrayMouseLDblEvent write FSystrayMouseLDblEvent;
property OnDblRClick:TNotifyEvent read FSystrayMouseRDblEvent write FSystrayMouseRDblEvent;
property OnLClick:TNotifyEvent read FSystrayMouseLClickEvent write FSystrayMouseLClickEvent;
property OnRClick:TNotifyEvent read FSystrayMouseRClickEvent write FSystrayMouseRClickEvent; { Published declarations }
end;procedure Register;
implementation
Procedure TSystray.MessageProc(Var Msg:TMessage)Message WM_SystrayMessag;
begin
IF msg.WParam=7 then
Case Msg.LParam of
512:if Assigned(FSystrayMouseMoveEvent) then FSystrayMouseMoveEvent(self);
513:if Assigned(FSystrayMouseLDownEvent) then FSystrayMouseLDownEvent(self);
514:if Assigned(FSystrayMouseLUpEvent) then
begin
FSystrayMouseLUpEvent(self);
if Assigned(FSystrayMouseLClickEvent) then FSystrayMouseLClickEvent(self);
end;
515:if Assigned(FSystrayMouseLDblEvent) then FSystrayMouseLDblEvent(self);
516:if Assigned(FSystrayMouseRDownEvent) then FSystrayMouseRDownEvent(self);
517:if Assigned(FSystrayMouseRUpEvent) then
begin
FSystrayMouseRUpEvent(self);
if Assigned(FSystrayMouseRClickEvent) then FSystrayMouseRClickEvent(self);
end;
518:if Assigned(FSystrayMouseRDblEvent) then FSystrayMouseRDblEvent(self);
end;
inherited;end;Procedure TSystray.SystrayADDIcon(SICON:TNOTIFYICONDATA);
begin
SICON.uCallbackMessage:=WM_SystrayMessage;
SICON.uFlags:=SICON.uFlags or NIF_MESSAGE;
SICON.cbSize:=Sizeof(SICON);
application.OnMessage:=MessageProc;
If Not Shell_NotifyIcon(NIM_ADD,@SICON) then
ShowMessage('系统图标添加错误');
end;
Procedure TSystray.SystrayDelIcon(SICON:PNOTIFYICONDATA);
begin
SICON^.uCallbackMessage:=WM_SystrayMessage;
SICON^.uFlags:=SICON.uFlags or NIF_MESSAGE;
SICON^.cbSize:=Sizeof(SICON);
If Not Shell_NotifyIcon(NIM_DELETE,SICON) then
ShowMessage('系统图标删除错误');
end;
Procedure TSystray.SystrayModIcon(SICON:PNOTIFYICONDATA);
begin
SICON^.uCallbackMessage:=WM_SystrayMessage;
SICON^.uFlags:=SICON.uFlags or NIF_MESSAGE;
SICON^.cbSize:=Sizeof(SICON);
If Not Shell_NotifyIcon(NIM_MODIFY,SICON) then
ShowMessage('系统图标修改错误');
end;
procedure Register;begin
RegisterComponents('Win32', [TSystray]);
end;end.
http://www.csdn.net/expert/topic/713/713598.xml?temp=.243725帖子
没有必要。
我已经删除。