Article View: borland.public.delphi.language.objectpascal
Article #216Re: Message methods
From: Peter Below (TeamB)
Date: Mon, 26 Jan 2004 18:59
Date: Mon, 26 Jan 2004 18:59
50 lines
3136 bytes
3136 bytes
In article <4014dcf8$1@newsgroups.borland.com>, Richard Bibby wrote: > I have an application that generates Crystal Reports document. Along the way > it creates an xml document (TXMLDocument) and a com object. > > This app works fine... and i have a single procedure call that does all the > hard work. > > The problem occurs when i start to use the wm_copydata message. > > I want other apps to be able to send a message to mine so that they can use > my app as a sort of "crystal reports print server" > > I have create a message method connected to the wm_copydata message. The > message identifies the document to be printed. > > However i am getting all sorts of problems in the wm_copydata message > method. It does not appear to like my call to create a xml document. > > The second line here throws an exception: > > //create DOM document instance > Reply := TXMLDocument.Create( nil ); And what is the exception message? > Reply is declared as IXMLDocument. > > I can place this code anywhere in my app, and it works. It just doesn't work > in the wm_copydata message method. COM things sometimes do not work properly inside cross-process message handlers since COM uses messages itself internally for marshalling data between threads. Sometimes this can be fixed simply be using the correct method to send the message (i.e. SendMessageTimeout with SMTO_NORMAL, not with SMTO_BLOCK. Do not use SendMessage!). If this does not work in your case one option is to make a copy of the passed data into local memory, call ReplyMessage to release the sender thread, and then process the data. An equivalent method would be to post a message to self in the receiving program (with the address of the local memory block) and process the data in the handler for this message. Both techniques decouple the original sender from processing the request. -- Peter Below (TeamB) Use the newsgroup archives : http://www.mers.com/searchsite.html http://www.tamaracka.com/search.htm http://groups.google.com http://www.prolix.be
Technical Details
Message-ID:
<VA.0000a905.004ecd2f@nomail.please>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<4014dcf8$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109d30,b2a3f9ffd0393f5c X-Google-Attributes: gid109d30,public X-Google-ArrivalTime: 2004-01-26 11:10:01 PST Date: Mon, 26 Jan 2004 19:59:20 +0100 Newsgroups: borland.public.delphi.language.objectpascal Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Newsreader: Virtual Access by Atlantic Coast PLC, http://www.atlantic-coast.com/va Organization: TeamB Message-ID: <VA.0000a905.004ecd2f@nomail.please> Subject: Re: Message methods From: "Peter Below (TeamB)" <100113.1101@compuXXserve.com> Reply-To: 100113.1101@compuXXserve.com References: <4014dcf8$1@newsgroups.borland.com> NNTP-Posting-Host: 62.226.187.154 X-Trace: newsgroups.borland.com 1075143447 62.226.187.154 (26 Jan 2004 10:57:27 -0700) Lines: 52 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail