<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
I dont think that will help. I think you need to get back to basics on
what this 3rd party DLL does, and what you are trying to do.<br>
<br>
How do you tell the dll to provide you with messages? surely there is
some procedure where you pass a handle as a parameter.<br>
<br>
if this is the case then there should be no problem setting up a single
instance of a THandle to receive the messages you are wanting, and then
you can write code to propagate this to any part of your application
using a stack of Bound Events.<br>
<br>
Do you want to send a snip of code demonstration how you communicate
with the dll? and what you want to do with the messages? Otherwise I
can't really offer any more help on the subject.<br>
<br>
regards<br>
Kyley<br>
<br>
Ross Levis wrote:
<blockquote cite="mid009d01c57b90$0f8e0580$5100a8c0@levis4" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.2668" name="GENERATOR">
<div><font face="Arial" size="2">Perhaps I should add TWinControl to
the class defination. The control is based on another control called
TACSControl which I can't change, so I believe I can do this:</font></div>
<div> </div>
<div><font face="Arial" size="2">TMyControl = class(TACSControl,
TWinControl);</font></div>
<div> </div>
<div><font face="Arial" size="2">Would my object then receive all
messages sent to the application that was not handled somewhere else?</font></div>
<div> </div>
<div><font face="Arial" size="2">Cheers,<br>
Ross.</font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">-----
Original Message ----- </div>
<div
style="background: rgb(228, 228, 228) none repeat scroll 0%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>From:</b>
<a title="KyleyHarris@gmail.com" href="mailto:KyleyHarris@gmail.com">Kyley
Harris</a> </div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>To:</b>
<a title="delphi@ns3.123.co.nz" href="mailto:delphi@ns3.123.co.nz">NZ
Borland Developers Group - Delphi List</a> </div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Sent:</b>
Tuesday, June 28, 2005 2:52 PM</div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Subject:</b>
[Spam] Re: [Spam] Re: [Spam] Re: [DUG] Intercepting messages in
separateunits</div>
<div><br>
</div>
if SendMessage is being used, then only the Handle that is sent the
message will receive it. If you delve into the VCL you will notice how
TForms and TApplication propagate messages to all their TWincontrol
children. I really cant help much without knowing the specific context
of this dll and how it binds itself into a windows handle, otherwise I
am just speculating on nothing.<br>
<br>
regards<br>
K<br>
<br>
Ross Levis wrote:
<blockquote cite="mid003b01c57b81$51b23bc0$5100a8c0@levis4"
type="cite">
<meta content="MSHTML 6.00.2900.2668" name="GENERATOR">
<div><font face="Arial" size="2">I read the following in the help
for TApplicationEvents:</font></div>
<div> </div>
<div><font color="#000080" face="Arial" size="2">OnMessage only
receives messages that are posted to the message queue, not those sent
directly with the Windows API SendMessage function</font></div>
<div> </div>
<div><font face="Arial" size="2">I believe it is SendMessage that
is being used to communicate with the application. I don't suppose
there are any other options?</font></div>
<div> </div>
<div><font face="Arial" size="2">Cheers,<br>
Ross.</font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">-----
Original Message ----- </div>
<div
style="background: rgb(228, 228, 228) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>From:</b>
<a title="KyleyHarris@gmail.com"
href="mailto:KyleyHarris@gmail.com">Kyley Harris</a> </div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>To:</b>
<a title="delphi@ns3.123.co.nz"
href="mailto:delphi@ns3.123.co.nz">NZ Borland Developers Group -
Delphi List</a> </div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Sent:</b>
Tuesday, June 28, 2005 12:32 PM</div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Subject:</b>
[Spam] Re: [Spam] Re: [DUG] Intercepting messages in separate units</div>
<div><br>
</div>
Yes. Use the TApplicationEvents object and the OnMessage event. This
captures all messages to the application.<br>
<br>
Ross Levis wrote:
<blockquote cite="mid00ab01c57b78$67121f20$5100a8c0@levis4"
type="cite">
<meta content="MSHTML 6.00.2900.2668" name="GENERATOR">
<div><font face="Arial" size="2">I found the problem and it's
now working. A silly error. Thanks for your help.</font></div>
<div> </div>
<div><font face="Arial" size="2">On a similar subject, </font><font
face="Arial" size="2">I was wondering if it's possible to obtain
messages sent to the Application object handle within a component
(separate unit), without altering any mainform source?</font></div>
<div> </div>
<div><font face="Arial" size="2">This DLL can also
communicate with other external applications by entering the Windows
class name to search and obtain an application handle, and I would like
to experiment with that.</font></div>
<div> </div>
<div><font face="Arial" size="2">Is that possible?</font></div>
<div> </div>
<div><font face="Arial" size="2"><font face="Arial" size="2">Thanks,</font></font></div>
<div><font face="Arial" size="2">Ross.</font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">-----
Original Message ----- </div>
<div
style="background: rgb(228, 228, 228) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>From:</b>
<a title="KyleyHarris@gmail.com"
href="mailto:KyleyHarris@gmail.com">Kyley Harris</a> </div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>To:</b>
<a title="delphi@ns3.123.co.nz"
href="mailto:delphi@ns3.123.co.nz">NZ Borland Developers Group -
Delphi List</a> </div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Sent:</b>
Tuesday, June 28, 2005 11:27 AM</div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Subject:</b>
[Spam] Re: [DUG] Intercepting messages in separate units</div>
<div><br>
</div>
Hi Ross. <br>
How and where are you telling the DLL which window handle to post its
messages to? <br>
<br>
is there a dll call such as
SetWindowHandleformessaging(MyInstance.Handle) ? or does it just happen
like magic?<br>
<br>
Ross Levis wrote:
<blockquote cite="mid021101c57b18$dad7bb50$5100a8c0@levis4"
type="cite">
<meta content="MSHTML 6.00.2900.2668" name="GENERATOR">
<div><font face="Arial" size="2">Hi Kyley</font></div>
<div> </div>
<div><font face="Arial" size="2">Yes, I do receive
WM_USER messages. This is how the DLL communicates. As I mentioned,
it works perfectly if I put all the message checking in the mainform,
but it doesn't work in the separate unit, even with the AllocateHWnd.</font></div>
<div> </div>
<div><font face="Arial" size="2">Here is all my relevant
code.</font></div>
<div> </div>
<div><font color="#000080" face="Arial" size="2">TMyComponent
= class(TComponent)<br>
private<br>
FHandle: HWnd;<br>
procedure WndProc(var Message: TMessage);</font></div>
<div><font color="#000080" face="Arial" size="2">end;</font></div>
<div> </div>
<div><font color="#000080" face="Arial" size="2">constructor
TMyComponent.Create;<br>
begin<br>
inherited Create(AOwner);<br>
FHandle := AllocateHWnd(WndProc);<br>
end;</font></div>
<div> </div>
<div><font color="#000080" face="Arial" size="2">destructor
TMyComponent.Destroy;<br>
begin<br>
DeallocateHWnd(FHandle);<br>
inherited Destroy;<br>
end;</font></div>
<div> </div>
<div><font color="#000080" face="Arial" size="2">procedure
TMyComponent.WndProc(var Message: TMessage);<br>
begin<br>
with Message do<br>
if Msg = WM_USER then<br>
begin</font></div>
<div><font color="#000080" face="Arial" size="2">
Result := lparam + wparam //(for example)</font></div>
<div><font color="#000080" face="Arial" size="2"> end</font></div>
<div><font color="#000080" face="Arial" size="2"> else
Result := DefWindowProc(FHandle, Msg, wParam, lParam);<br>
end;</font></div>
<div> </div>
<div><font face="Arial" size="2">I get a couple messages
when the program loads but I never get Msg = WM_USER.</font></div>
<div><font face="Arial" size="2">Do you see any problems
with this code?</font></div>
<div> </div>
<div><font face="Arial" size="2">The following code,
however, when placed in the mainform does detect WM_USER messages.</font></div>
<div> </div>
<div><font color="#000080" face="Arial" size="2">TForm1 =
class(TForm)<br>
...</font></div>
<div><font color="#000080" face="Arial" size="2">
procedure WMUSER(var Message: TMessage); message WM_USER;</font></div>
<div><font color="#000080" face="Arial" size="2">end;</font></div>
<div> </div>
<div><font color="#000080" face="Arial" size="2">procedure
TForm1.WMUSER(var Message: TMessage);<br>
begin<br>
with Message do<br>
if Msg = WM_USER then showmessage('It Works!');<br>
end;</font></div>
<div> </div>
<div><font face="Arial" size="2">I've tried different
combinations of the syntax, including the <font color="#000080">message
WM_USER;</font><font color="#000000"> bit in the unit but it doesn't
make any difference at all. In fact I still get other messages when
the program starts.</font></font></div>
<div> </div>
<div><font face="Arial" size="2">Thanks for the help.</font></div>
<div><font face="Arial" size="2">Ross.</font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">-----
Original Message ----- </div>
<div
style="background: rgb(228, 228, 228) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>From:</b>
<a title="KyleyHarris@gmail.com"
href="mailto:KyleyHarris@gmail.com">Kyley Harris</a> </div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>To:</b>
<a title="delphi@ns3.123.co.nz"
href="mailto:delphi@ns3.123.co.nz">NZ Borland Developers Group -
Delphi List</a> </div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Sent:</b>
Monday, June 27, 2005 10:01 PM</div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Subject:</b>
[Spam] Re: [DUG] Intercepting messages in separate units</div>
<div><br>
</div>
Try the wrapper class just incase you have made a blooper. but it is
unlikely that you will ever receive a message with the ID WM_USER. that
is simply an offset to coordinate with windows messages. eg
WM_USERLOGON = WM_USER+1 is an example of a user defined message.<br>
<br>
then <br>
myobject = class(TObject)<br>
procedure WMUSERLOGON(var msg:TMessage);message WM_USERLOGON; <br>
end;<br>
<br>
the above procedure will only ever receive that one message. You need
to know exactly what messages you are expecting from the dll.<br>
<br>
if you use my wrapper, and attached an instance of the above object to
message handler it will route the messages to that instance..<br>
<br>
Ross Levis wrote:
<blockquote
cite="mid019b01c57af5$e31e7f10$5100a8c0@levis4" type="cite">
<meta content="MSHTML 6.00.2900.2668" name="GENERATOR">
<div><font face="Arial" size="2">Thanks for that
Kyley. I managed to implement AllocateHWnd etc, and everything appears
correct and logical. It's picking up some Windows messages but not the
WM_USER messages being sent. WM_USER is message number 1024. I'm
getting Message.Msg = 28 and that's about it.</font></div>
<div> </div>
<div><font face="Arial" size="2">I tried the same
code in the mainform as a test and this worked but only after I
specified the following:</font></div>
<div><font face="Arial" size="2">
<div><font face="Arial" size="2">procedure
MyMessage(var Message: TMessage); message WM_USER;</font></div>
<div> </div>
</font></div>
<div><font face="Arial" size="2">If I leave off
"message WM_USER", then nothing gets through to the procedure in the
mainform at all.</font></div>
<div> </div>
<div><font face="Arial" size="2">I tried this in the
unit and it doesn't make any difference. Message 28 is still getting
to the procedure and no 1024.</font></div>
<div> </div>
<div><font face="Arial" size="2">You can tell I'm no
expert when it comes to this. Do I need to use your fancy looking
wrapper class?</font></div>
<div> </div>
<div><font face="Arial" size="2">I must be missing
something.</font></div>
<div> </div>
<div><font face="Arial" size="2">Thanks,</font></div>
<div><font face="Arial" size="2">Ross.</font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">-----
Original Message ----- </div>
<div
style="background: rgb(228, 228, 228) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>From:</b>
<a title="KyleyHarris@gmail.com"
href="mailto:KyleyHarris@gmail.com">Kyley Harris</a> </div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>To:</b>
<a title="delphi@ns3.123.co.nz"
href="mailto:delphi@ns3.123.co.nz">NZ Borland Developers Group -
Delphi List</a> </div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Sent:</b>
Monday, June 27, 2005 7:13 PM</div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Subject:</b>
[Spam] Re: [DUG] Intercepting messages in separate units</div>
<div><br>
</div>
in the forms unit<br>
<br>
function AllocateHWnd(Method: TWndMethod): HWND; deprecated; { moved
to Classes.pas }<br>
{$EXTERNALSYM AllocateHWnd}<br>
procedure DeallocateHWnd(Wnd: HWND); deprecated; { moved
to Classes.pas }<br>
<br>
<br>
read the help will sort you out just fine<br>
<br>
Ross Levis wrote:
<blockquote
cite="mid014401c57ae7$48177ca0$5100a8c0@levis4" type="cite">
<meta content="MSHTML 6.00.2900.2668"
name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">I'm writing a
component which communicates with a 3rd party DLL using WM_USER
messages. After loading the DLL, I need to tell the DLL the handle to
send user messages back to, so my unit can intercept them, but I don't
know where to get a handle from. I know how to do it in the mainform
of a program but not in a separate unit. The messages sent to the
mainform do not appear to reach my unit.</font></div>
<div> </div>
<div><font face="Arial" size="2">What do I need
to do to make this happen?</font></div>
<div> </div>
<div><font face="Arial" size="2"><font
color="#000000">Thanks,</font></font></div>
<div><font face="Arial" size="2"><font
color="#000000">Ross.</font></font></div>
<pre wrap=""><hr size="4" width="90%">
_______________________________________________
Delphi mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a>
<a class="moz-txt-link-freetext"
href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a>
</pre>
</blockquote>
<hr> _______________________________________________<br>
Delphi mailing list<br>
<a class="moz-txt-link-abbreviated"
href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a><br>
<a class="moz-txt-link-freetext"
href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a><br>
</blockquote>
<pre wrap=""><hr size="4" width="90%">
_______________________________________________
Delphi mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a>
<a class="moz-txt-link-freetext"
href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a>
</pre>
</blockquote>
<hr> _______________________________________________<br>
Delphi mailing list<br>
<a class="moz-txt-link-abbreviated"
href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a><br>
<a class="moz-txt-link-freetext"
href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a><br>
</blockquote>
<pre wrap=""><hr size="4" width="90%">
_______________________________________________
Delphi mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a>
<a class="moz-txt-link-freetext"
href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a>
</pre>
</blockquote>
<hr> _______________________________________________<br>
Delphi mailing list<br>
<a class="moz-txt-link-abbreviated"
href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a><br>
<a class="moz-txt-link-freetext"
href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a><br>
</blockquote>
<pre wrap=""><hr size="4" width="90%">
_______________________________________________
Delphi mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a>
<a class="moz-txt-link-freetext"
href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a>
</pre>
</blockquote>
<hr> _______________________________________________<br>
Delphi mailing list<br>
<a class="moz-txt-link-abbreviated"
href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a><br>
<a class="moz-txt-link-freetext"
href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a><br>
</blockquote>
<pre wrap=""><hr size="4" width="90%">
_______________________________________________
Delphi mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a>
<a class="moz-txt-link-freetext"
href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a>
</pre>
</blockquote>
<p> </p>
<hr> _______________________________________________<br>
Delphi mailing list<br>
<a class="moz-txt-link-abbreviated" href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a><br>
<a class="moz-txt-link-freetext" href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a><br>
</blockquote>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
Delphi mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a>
<a class="moz-txt-link-freetext" href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a>
</pre>
</blockquote>
</body>
</html>