我们在pb中截获到49417消息,在delphi里面我们需要对该消息进行处理,但是delphi所能处理的消息必须是小于49151.我们不知道delphi对这种大号消息号是怎么样处理的。有熟悉的高手请指教
解决方案 »
- 双击cxGrid列头的分割线,自动适应列宽,但同时执行了OnDblClick
- 请教高手,在TreeView中如何更改选中的节点的图标?
- 您接过项目吗??欢迎大家进来讨论一下现在市场行价
- 不算是问题,只是有点奇怪!大家来发表自己的看法吧
- 如何使用delphi的帮助?关于方法论的讨论!!!!!!!!!!!!!!!
- 郁闷!我的delphi7出错了?
- 關於時間處理的問題,很簡單,可是我不知怎麼做.
- *.*
- 请各位谈谈怎样才算是真正的delphi程序员
- ShellListView1有没可能实现把“文件名”为“A开头”的列出?
- treeview從一個節點移到另一節點是個麼事件呀
- 我要在一周内熟悉delphi,请教?
你确定么?那么为什么sendmessage的第二个参数是cardinal类型的?
Result := DefWindowProc(Handle, MsgID, wParam, lParam);
end; begin
// 首先使用RegisterClass()注册窗体的类,这可不是Delphi数据类型中的类哦!
wc.style := CS_HREDRAW or CS_VREDRAW;
wc.lpfnWndProc := @MainWndProc; // 消息处理函数的地址
wc.hInstance := hInstance; // 程序的句柄,同时也是基地址
wc.hIcon := LoadIcon(0, PChar(IDI_APPLICATION));
wc.hCursor := LoadCursor(0, IDC_ARROW); // 图标
wc.hbrBackground := GetStockObject(WHITE_BRUSH); // 背景画刷
wc.lpszClassName := ClassName; // 前面定义的常量
if RegisterClass(wc) = 0 then Halt(0);
hWnd := CreateWindowEx(0,
ClassName, // 刚才注册的类的名称
'Sample', // 窗体的标题
WS_OVERLAPPEDWINDOW, // 窗体有标题栏、系统菜单、最大小化菜单,以及拉伸边框
Integer(CW_USEDEFAULT),
Integer(CW_USEDEFAULT),
Integer(CW_USEDEFAULT),
Integer(CW_USEDEFAULT),
0,
0,
hInstance,
nil
);
if hWnd = 0 then Halt(0);
ShowWindow(hWnd, CmdShow);
UpdateWindow(hWnd);
while GetMessage(Msg, 0, 0, 0) do begin
TranslateMessage(Msg);
DispatchMessage(Msg); // 该API将消息分派到相应的窗体消息处理函数
end;
ExitCode := Msg.wParam;
end.
那就重载wndproc:unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure wndproc(var msg:tmessage);override;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
sendmessage(handle,49157,0,0);
end;procedure TForm1.wndproc(var msg: tmessage);
begin
if msg.Msg=49157 then
beep
else
inherited;end;end.
WM_USER to $07FF(49151): custom use
WM_APP to $BFFF: use for comunicating between applications
$C000 to $FFFF: for string message (see also registerwindowmessage)
> $FFFF: reserve by future use
WM_USER to $7FFF(49151): custom use
WM_APP to $BFFF: use for comunicating between applications
$C000 to $FFFF: for string message (see also registerwindowmessage)
> $FFFF: reserve by future use
但是不能得到sendmessage和perform的消息。
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure myonmessage(var Msg: TMsg; var Handled: Boolean);
procedure wndproc(var msg:tmessage);override;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
function mousehookproc(ncode:smallint;wparam,lparam:integer):integer;stdcall;
beginend;
procedure TForm1.Button1Click(Sender: TObject);
begin
postmessage(handle,49157,0,0);
end;
procedure TForm1.wndproc(var msg: tmessage);
begin
if msg.Msg=49157 then
beep
else
inherited;end;procedure TForm1.FormCreate(Sender: TObject);
begin
application.OnMessage:=myonmessage;
end;procedure TForm1.myonmessage(var Msg: TMsg; var Handled: Boolean);
begin
if msg.message=49157 then
begin
showmessage('49157');
end;
end;end.