Article View: borland.public.delphi.language.objectpascal
Article #24Problem with DLLs and Application.OnMessage - Event
From: Ladidadi
Date: Wed, 11 Aug 2004 14:41
Date: Wed, 11 Aug 2004 14:41
94 lines
3419 bytes
3419 bytes
I have a problem using the Application.OnMessage Event in a .dll:
I'm working in Delphi 7 on a CLX-Tool. The "Application" variables in
Clx-Tools do not have an "OnMessage"-Event (because it wouldn't be
compatible with linux). So I had to create a .dll file to interact via
messages to a second exe-file (The tool will be compiled for linux and
windows and some functions will only work in windows; that's okay, I
accepted it).
The communication with messages works fine in one way: from the dll to
the exe. But it doesn't work at all vice versa: The messages sent from
the exe to the dll seem not to be received by the OnMessage event of
the dll.
The tool works in the following way:
type
TForm1 = class(TForm)
procedure AppOnMessage(Var Msg: TMSg; Var Handled: Boolean);
...
end;
var
Procedure ProgStart(); stdcall; //Procedure called by the main
program
...
implementation
procedure ProgStart();
begin
Application.CreateHandle; // else the handle of the dll would be
0...
Application.OnMessage := Form1.AppOnMessage;
...
end;
Procedure TForm1.AppOnMessage(var Msg: TMsg; var Handled: Boolean);
Begin
Case msg.message Of
WM_USER + 123:
Begin
...
End;
WM_USER + 456:
Begin
...
End;
...
end;
I also tried to create event handlers like...
type
TForm1 = class(TForm)
...
public
procedure WMUSER1(var Msg: TMessage); message WM_USER + 123;
procedure WMUSER2(var Msg: TMessage); message WM_USER + 456;
end;
procedure TForm1.WMUSER1(var Msg: TMessage);
Begin
...
end;
procedure TForm1.WMUSER2(var Msg: TMessage);
Begin
...
end;
...but that didn't work, too.
The exe-file the dll communicates with cannot be the problem. It sends
its messages with the postmessage() procedure and worked well in the
old version, (where it communicated directly with the main program).
The code was the same in the older version, but it was directly in the
main program's source, not the one of the dll (as i explained this is
the only possible way now)...
I checked the dll with the debugger and realised, that the
AppOnMessage Method is not even visited. Same thing with the event
handlers: no activity in it although I'm 110% sure that there are in
fact messages sent from the exe-file to the dll, they just don't seem
to reach it...
Can anybody please help me and tell me if there is a possibility for a
dll file to receive windows messages?
Thanx!
Technical Details
Message-ID:
<d35d6a79.0408110641.4ebecad2@posting.google.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!postnews2.google.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 109d30,5dd1587f18e9daa7,start X-Google-Thread: fd817,5dd1587f18e9daa7,start X-Google-Attributes: gid109d30,gidfd817,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews2.google.com!not-for-mail From: ladidadi@onlinehome.de (Ladidadi) Newsgroups: borland.public.delphi.language.objectpascal,alt.comp.lang.borland-delphi Subject: Problem with DLLs and Application.OnMessage - Event Date: 11 Aug 2004 07:41:17 -0700 Organization: http://groups.google.com Lines: 94 Message-ID: <d35d6a79.0408110641.4ebecad2@posting.google.com> NNTP-Posting-Host: 217.235.156.82 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1092235296 30368 127.0.0.1 (11 Aug 2004 14:41:36 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 11 Aug 2004 14:41:36 +0000 (UTC)