home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / ant12 / tutorial.ht_ / tutorial.ht
Encoding:
Text File  |  1998-02-08  |  5.5 KB  |  121 lines

  1. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
  2. <html>
  3.  
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <meta name="Description" content="Antanna ocx Control Documentation">
  7. <meta name="KeyWords" content="Antanna, Control, Documentation, Visual Basic, OCX">
  8. <meta name="GENERATOR" content="Microsoft FrontPage 3.0">
  9. <title>Antenna Control Tutorial</title>
  10. </head>
  11.  
  12. <body bgcolor="#FFFFFF" text="#000000" link="#0000EE" vlink="#551A8B" alink="#FF0000">
  13.  
  14. <p>[<a href="index.htm">Antenna Documentation</a>]</p>
  15.  
  16. <hr>
  17.  
  18. <h2>Antenna Control Tutorial</h2>
  19.  
  20. <blockquote>
  21.   <p>This tutorial explains how to use Antenna control properly in Visual Basic 4.0 or
  22.   above.<ul>
  23.     <li><a href="#T0">Antenna Basics</a></li>
  24.     <li><a href="#T1">How to Set (or Change) Target hWnd</a></li>
  25.     <li><a href="#T2">How to Trap Messages</a></li>
  26.     <li><a href="#T3">How to Respond to Messages</a></li>
  27.     <li><a href="#T4">How to Destroy Antenna Control</a></li>
  28.   </ul>
  29.   <p> </p>
  30.   <h3><a name="T0">Antenna</a> Basics</h3>
  31.   <blockquote>
  32.     <p>Antenna control is an OCX that allows Visual Basic applications to trap and process
  33.     Windows messages that are not handled directly by Visual Basic.</p>
  34.     <p>When you specify the Target hWnd, Antenna starts to monitor all messages that were
  35.     originally sent to the Target hWnd. You can then add messages you want to process.</p>
  36.     <p>Antenna control was tested under Visual Basic 4.0 using Windows 95.</p>
  37.     <p> </p>
  38.   </blockquote>
  39.   <h3><a name="T1">How</a> to Set (or Change) Target hWnd</h3>
  40.   <blockquote>
  41.     <p>When you create Antenna, the first thing you have to do is to set the Target hWnd, so
  42.     that Antenna will start to trap messages of the Target hWnd.</p>
  43.     <p>To set the Target hWnd, use the method <a href="reference.htm#SetTargetWnd">SetTargetWnd()</a>,
  44.     like in the following example:</p>
  45.     <pre>...
  46. Antenna1.SetTargetWnd(Text1.hWnd)
  47. ...</pre>
  48.     <p>One Antenna can only have one Target hWnd. To trap multiple windows' messages, you need
  49.     to create multiple Antenna.</p>
  50.     <p>When you change the Target hWnd, all messages it used to trap will be cleared. You have
  51.     to use AddPreMsg() and AddPostMsg() methods to add messages.</p>
  52.     <p> </p>
  53.   </blockquote>
  54.   <h3><a name="T2">How</a> to Trap Messages</h3>
  55.   <blockquote>
  56.     <p>Once you create Antenna, you have to notify Antenna which messages to trap. You can
  57.     trap messages either before or after the original function of the Target hWnd is
  58.     processed.</p>
  59.     <p>If you want to process messages before the original function, use the method <a
  60.     href="reference.htm#AddPreMsg">AddPreMsg()</a> as in the following example:</p>
  61.     <pre>Const WM_DROPFILES &23
  62. ...
  63. Antenna1.AddPreMsg(WM_DROPFILES, True)
  64. ...</pre>
  65.     <p>The second parameter indicates whether the message should be "eaten".</p>
  66.     <p>To process messages after the original function, use the method <a
  67.     href="reference.htm#AddPostMsg">AddPostMsg()</a> as in the following example:</p>
  68.     <pre>Const WM_DROPFILES &23
  69. ...
  70. Antenna1.AddPostMsg(WM_DROPFILES)
  71. ...</pre>
  72.     <p>You can add 30 messages at maximum (15 in AddPreMsg() and 15 in AddPostMsg()). When you
  73.     exceed 15, the subsequent messages will not be added.</p>
  74.     <p>You cannot remove messages you added unless you call <a
  75.     href="reference.htm#SetTargetWnd">SetTragetWnd()</a> to change the Target hWnd.</p>
  76.     <p> </p>
  77.   </blockquote>
  78.   <h3><a name="T3">How</a> to Respond to Messages</h3>
  79.   <blockquote>
  80.     <p>When Antenna receives a message, it calls OnTrap() function of itself. You can respond
  81.     to the message inside <a href="reference.htm#OnTrap">OnTrap()</a> as in the following
  82.     example:</p>
  83.     <pre>Private Sub OnTrap(hWnd As Long, nMsg As Long, wParam As Long, lParam As Long)
  84.     MsgBox "Message was trapped"
  85. End Sub</pre>
  86.     <p align="left">This function is called either before or after the Target hWnd handled the
  87.     message, depending on how you added the message. If you used <a
  88.     href="reference.htm#AddPreMsg">AddPreMsg()</a>, it is called before the original function.
  89.     If you used <a href="reference.htm#AddPostMsg">AddPostMsg()</a>, it is called after the
  90.     original function.</p>
  91.     <p> </p>
  92.   </blockquote>
  93.   <h3><a name="T4">How</a> to Destroy Antenna Control</h3>
  94.   <blockquote>
  95.     <p>When you are using Antenna in Visual Basic's "Run" mode, you will need to
  96.     destroy Antenna explicitly. This can be done by using <a href="reference.htm#DestroyAll">DestroyAll()</a>
  97.     method. The following example illustrates the point:</p>
  98.     <pre>Private Sub Unload()
  99.     Antenna1.DestroyAll()
  100. End Sub</pre>
  101.     <p>You will need to remember the following points:<ol>
  102.       <li>Call DestroyAll() once and only once whether or not you created multiple Antenna.
  103.         DestroyAll() can be called from any Antenna.</li>
  104.       <li>The call to call to DestroyAll() should be made in Unload() method of the main window.</li>
  105.       <li>The call to DestroyAll() is <b>not</b> necessary when you create EXE. Unexpected result
  106.         might happen if you call the function from EXE.</li>
  107.     </ol>
  108.     <p> </p>
  109.   </blockquote>
  110. </blockquote>
  111.  
  112. <hr>
  113.  
  114. <p align="center">If you have any comments or questions, please contact <a
  115. href="mailto:integer@pair.com">integer@pair.com</a>.</p>
  116.  
  117. <p align="center">Copyright ⌐ 1998 <a href="http://www.integer.pair.com/">Integer</a> </p>
  118. </body>
  119. </html>
  120.  
  121.