Problem with DLLs and Application.OnMessage - Event

From: Ladidadi (ladidadi_at_onlinehome.de)
Date: 08/11/04


Date: 11 Aug 2004 07:41:17 -0700

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!



Relevant Pages

  • Re: how to create a thread and a modal dialog from a regular dll?
    ... And I have been able to display a dialog box already from the dll. ... >>> Communication back to the main program will depend on what it expects, ... you may end up with a confusing interface if you expect things ... it should only post messages to the UI thread or UI windows. ...
    (microsoft.public.dotnet.languages.vc)
  • Problem with DLLs and Application.OnMessage - Event
    ... I have a problem using the Application.OnMessage Event in a .dll: ... I'm working in Delphi 7 on a CLX-Tool. ... windows and some functions will only work in windows; ... The communication with messages works fine in one way: ...
    (alt.comp.lang.borland-delphi)
  • Re: .Net packaging/wrapper application?
    ... it just didn't work well in reality due to DLL ... Windows works is to look in the executable's directory for a needed DLL ... the way apps used to work when they developed Windows. ... Looks to me like Jim is looking for the .NET equivalent of compiling ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Unnown process... 5eplorer.exe
    ... do not remove the cause (a "super"-hidden .dll program) but only remove ... symptom files and registry settings. ... It has all permissions but 'copy' denied to everyone, ... then by using the Windows XP Recovery Console. ...
    (microsoft.public.win2000.general)
  • Re: WinSxS, functional under 2k ?
    ... The newSide-by-Side Assembly technology was introduced with Windows XP to help reduce or eliminate DLL Hell. ... If you recall earlier Windows versions, like Windows 95, when you installed an application you were warned if the installer tried to replace a DLL from the system folder with an older version and you were asked if you wanted to accept the change. ... Until Windows XP it wasn't so easy to use different versions of shared system DLLs, that is what the new Side-by-Side assemblies attempts to resolve. ...
    (microsoft.public.win2000.general)