消息问题!十万火急!在线请求! ( 积分: 58 )

  • 主题发起人 主题发起人 boycxd
  • 开始时间 开始时间
B

boycxd

Unregistered / Unconfirmed
GUEST, unregistred user!
用DELPHI调用VC++写的DLL,有个函数是请求数据的函数,如何在DLPHI中定义消息来接收DLL发过来的消息,以备进行必要的处理?就这么多分了。比较吉利(58分)在线等。
有个VC++的例子。但是不知道DELPHI如何实现的!
UINT nReplyMsg = RegisterWindowMessage("SCDemo Reply Message");

ON_REGISTERED_MESSAGE(nReplyMsg, OnReply)

sca.m_nMsg = nReplyMsg;

ON_REGISTERED_MESSAGE(nReplyMsg, OnReply)

LRESULT CSCDemoDlg::OnReply(WPARAM wParam, LPARAM lParam)

afx_msg LRESULT OnReply(WPARAM wParam, LPARAM lParam);
 
unit Unit2;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm2 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
//收到消息触发的事件
Function OnReply(wParam : Integer; lParam : Integer):HRESULT;
protected
procedure WndProc(var Message: TMessage); override;
public
end;

var
Form2: TForm2;


implementation

{$R *.dfm}

var
nReplyMsg : UINT;

{ TForm2 }
//加个按钮测试
procedure TForm2.Button1Click(Sender: TObject);
begin
SendMessage(Self.Handle,nReplyMsg,0,0);
end;

function TForm2.OnReply(wParam, lParam: Integer): HRESULT;
begin
//做你要做的事情
Caption := '消息来了';
end;

procedure TForm2.WndProc(var Message: TMessage);
begin
if Message.Msg = nReplyMsg then
begin
OnReply(Message.WParam, Message.LParam);
end;
inherited WndProc(Message);
end;

initialization
nReplyMsg := RegisterWindowMessage('SCDemo Reply Message');
end.
 
接受答案了.
 
后退
顶部