<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>
myOffice Email Message
</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="date" content="2002-11-01">
<style type="text/css">
</style>
</head>
<body>
<span style=
"color:#FF0000 "><b><span style=
"font-family:MS Sans Serif ">[Reply]</span></b></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#000000 ">Hi all,</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#000000 ">To "send a string" using windows messaging, use Global Atoms, and send the reference to the Atom in the Windows Message.</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#000000 ">Look at:</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#000000 ">http://www.delphipages.com/threads/thread.cfm?ID=24029&G=24027</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#000000 ">cheers</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#000000 ">Gary</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#000000 ">A</span><span style=
"color:#FF0000 "><b>t 19:43 on 24/11/2005 you wrote </b></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>To : rohit@cfl.co.nz,delphi@ns3.123.co.nz</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>CC : </span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>From: Kyley Harris, kyleyharris@gmail.com</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>Content Type: text/plain</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>Attached: </span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>There are two basic ways to send a string, seeing as we are talking </span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>postmessage,</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>here is the fugly one.</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>p:phar;</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>GetMem(p,length(data));</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>move(data[1],p^,length(data));</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>postmessage(bla bla , integer(p));</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>remember to free mem on the other side.</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>Better and nicer way</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>TString = class(TObject)</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">> property data:string;</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>end;</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>Create and send a reference to this, and free it when you are finished.</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>remember none of these options is safe outside of your own application.</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>On Thu, 24 Nov 2005 17:43:51 +1300, Rohit Gupta <rohit@cfl.co.nz> wrote:</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> I cant see how it can be safe. I was stumped as well when I wanted</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> to send a string in a message. I had to abandon my ideas.... :-( Let</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> me know if you have any joy.</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> From: "Paul Lowman" <paul_lowman@xtra.co.nz></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> To: "Delphi List" <delphi@delphi.org.nz></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> Date sent: Thu, 24 Nov 2005 16:22:04 +1300</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> Copies to: </span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> Subject: [DUG] Reference counting</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> Send reply to: NZ Borland Developers Group - Delphi List </span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> <delphi@ns3.123.co.nz></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> <mailto:delphi-request@ns3.123.co.nz?subject=unsubscribe></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> <mailto:delphi-request@ns3.123.co.nz?subject=subscribe></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> [ Double-click this line for list subscription options ]</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> Heres one for the gurus -</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> Assume a long string variable is declared locally to a method and is</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> assigned a string and the string variable is then typecast as an integer </span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> and</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> used in - say - a windows message by assigning it to the message lparam.</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> The question is when the message is received by another form / thread is </span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> it</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> valid to then typecast the lparam back to a string and use it ?</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> I have tried many variations of this scenario and it seems to work OK </span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> but am</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> uneasy about whether or not this is safe. I assume it isn't as the local</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> string variable (which points to the actual string) is on the stack and </span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> is</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> not maintained after the method is exited but what I really am concerned</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> about is the reference count for the string - has it been increased by</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> typecasting it to an integer / pointer whatever ...</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> I have used some of Marco Cantu's code to try and examine the strings</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> reference count and it always appears to be -1 if the string is a local</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> variable although it works correctly for field or global.</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> All very confusing :-)</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> I would like to know how the code knows when to inc / dec / dispose the</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> stirng / array reference count.</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> Cheers</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> Paul Lowman</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> _______________________________________________</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> Delphi mailing list</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> Delphi@ns3.123.co.nz</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> http://ns3.123.co.nz/mailman/listinfo/delphi</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> Regards</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> Rohit</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> ======================================================================</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> CFL - Computer Fanatics Ltd. 21 Barry's Point Road, AKL, New Zealand</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> PH (649) 489-2280</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> FX (649) 489-2290</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> email rohit@cfl.co.nz or r.gupta@xtra.co.nz</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> ======================================================================</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> _______________________________________________</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> Delphi mailing list</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> Delphi@ns3.123.co.nz</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>> http://ns3.123.co.nz/mailman/listinfo/delphi</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">></span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>-- </span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>Kyley Harris</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>+64-21-671821</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>_______________________________________________</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>Delphi mailing list</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>Delphi@ns3.123.co.nz</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">>http://ns3.123.co.nz/mailman/listinfo/delphi</span></span>
<p>
<span style=
"font-family:MS Sans Serif "><span style=
"color:#008000 ">></span></span><p>
<font face=arial size = 1 color = Navy><DIV style="WIDTH: 260px; HEIGHT: 50px"><MARQUEE id=marquee1 style="WIDTH: 260px; HEIGHT: 200px" trueSpeed scrollAmount=5 scrollDelay=20 direction=right behavior=slide loop=1 border="2"><hr><table><tr><td><FONT color=black size=4 face = "helvetica,verdana,arial">Gary Benner </FONT></td></tr><tr><td><FONT face="arial, arial, helvetica, sans-serif" color=black size=2>e-Engineer, Lecturer, and Software Developer</FONT></td></tr><br>
<tr><td bgcolor=><FONT face="arial, arial, helvetica, sans-serif" color=#000099 size=2><B><A HREF="http://www.123.co.nz" style="text-decoration:none; color:blue">123 Internet Limited</A></B></FONT></td></tr><tr><td bgcolor=><FONT face="arial, arial, helvetica, sans-serif" color=#000099 size=2><B><A HREF="http://www.waiariki.ac.nz" style="text-decoration:none; color:#993333">Waiariki Institute of Technology</A></B></FONT></td></tr><tr><td bgcolor=><FONT face="arial, arial, helvetica, sans-serif" color=#CECE00 size=2><B><A HREF="http://www.sunshinebags.co.nz" style="text-decoration:none; color:#CECE00">Sunshine Garden Bag Co.</A></B></FONT></td></tr><tr><td bgcolor=><FONT face="arial, arial, helvetica, sans-serif" color=red size=2><B><A HREF="http://www.sommnet.com" style="text-decoration:none; color:red" >Sommnet.com Limited</A></B></FONT></td></tr><tr><td><font face = 22helvetica,verdana,arial" size = 1>Mob: 021 966 992</font></td></tr><tr><td><font face = "helvetica,verdana,arial" size = 1>Email: <A href="mailto:gary@123.co.nz" >gary@123.co.nz</A> </font></td></tr></table></MARQUEE></DIV><br>
<br>
Ref#: 41006<br>
<br>
</body>
</html>