home *** CD-ROM | disk | FTP | other *** search
/ Eagles Nest BBS 6 / Eagles_Nest_Mac_Collection_Disc_6.TOAST / Windows / VisBasAPIex / VBAPIGUIDE.image / DLLPARAM.ZIP / DLLPARAM.FRM < prev    next >
Text File  |  1994-01-23  |  10KB  |  387 lines

  1. VERSION 2.00
  2. Begin Form dllparam 
  3.    Caption         =   "DLL parameter tester"
  4.    ClientHeight    =   4740
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1485
  7.    ClientWidth     =   7365
  8.    Height          =   5145
  9.    Left            =   1035
  10.    LinkMode        =   1  'Source
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   4740
  13.    ScaleWidth      =   7365
  14.    Top             =   1140
  15.    Width           =   7485
  16.    Begin CommandButton Command3 
  17.       Caption         =   "Variant"
  18.       Height          =   375
  19.       Left            =   3180
  20.       TabIndex        =   21
  21.       Top             =   4200
  22.       Width           =   1275
  23.    End
  24.    Begin CommandButton Command2 
  25.       Caption         =   "VariantByVal"
  26.       Height          =   375
  27.       Left            =   1740
  28.       TabIndex        =   20
  29.       Top             =   4200
  30.       Width           =   1335
  31.    End
  32.    Begin CommandButton Command1 
  33.       Caption         =   "VBArray"
  34.       Height          =   375
  35.       Left            =   240
  36.       TabIndex        =   19
  37.       Top             =   4200
  38.       Width           =   1335
  39.    End
  40.    Begin CommandButton TestIntByval 
  41.       Caption         =   "ReceivesInteger(5)"
  42.       Height          =   375
  43.       Left            =   240
  44.       TabIndex        =   0
  45.       Top             =   240
  46.       Width           =   2175
  47.    End
  48.    Begin CommandButton TestIntByref 
  49.       Caption         =   "Add5To5"
  50.       Height          =   375
  51.       Left            =   2640
  52.       TabIndex        =   4
  53.       Top             =   240
  54.       Width           =   1575
  55.    End
  56.    Begin CommandButton TestControl 
  57.       Caption         =   "Get Hwnds"
  58.       Height          =   375
  59.       Left            =   4560
  60.       TabIndex        =   10
  61.       Top             =   240
  62.       Width           =   1215
  63.    End
  64.    Begin CommandButton TestLongByval 
  65.       Caption         =   "ReceivesLong(6)"
  66.       Height          =   375
  67.       Left            =   240
  68.       TabIndex        =   1
  69.       Top             =   720
  70.       Width           =   2175
  71.    End
  72.    Begin CommandButton TestLongByref 
  73.       Caption         =   "Add5To6"
  74.       Height          =   375
  75.       Left            =   2640
  76.       TabIndex        =   5
  77.       Top             =   720
  78.       Width           =   1575
  79.    End
  80.    Begin CommandButton TestSingleByval 
  81.       Caption         =   "ReceivesSingle(1.59)"
  82.       Height          =   375
  83.       Left            =   240
  84.       TabIndex        =   2
  85.       Top             =   1200
  86.       Width           =   2175
  87.    End
  88.    Begin CommandButton TestSingleByref 
  89.       Caption         =   "Add5To1.59"
  90.       Height          =   375
  91.       Left            =   2640
  92.       TabIndex        =   6
  93.       Top             =   1200
  94.       Width           =   1575
  95.    End
  96.    Begin CommandButton TestCurrencyByval 
  97.       Caption         =   "ReceivesCurrency(1.2345)"
  98.       Height          =   375
  99.       Left            =   4440
  100.       TabIndex        =   15
  101.       Top             =   1200
  102.       Width           =   2775
  103.    End
  104.    Begin CommandButton TestDoubleByval 
  105.       Caption         =   "ReceivesDouble(3.145)"
  106.       Height          =   375
  107.       Left            =   240
  108.       TabIndex        =   3
  109.       Top             =   1680
  110.       Width           =   2175
  111.    End
  112.    Begin CommandButton TestDoubleByref 
  113.       Caption         =   "Add5To3.145"
  114.       Height          =   375
  115.       Left            =   2640
  116.       TabIndex        =   7
  117.       Top             =   1680
  118.       Width           =   1575
  119.    End
  120.    Begin CommandButton TestCurrencyByref 
  121.       Caption         =   "AddPennyToCurrency(1.23)"
  122.       Height          =   375
  123.       Left            =   4440
  124.       TabIndex        =   16
  125.       Top             =   1680
  126.       Width           =   2775
  127.    End
  128.    Begin CommandButton TestString 
  129.       Caption         =   "ReceivesString ""Hello"""
  130.       Height          =   375
  131.       Left            =   240
  132.       TabIndex        =   8
  133.       Top             =   2160
  134.       Width           =   2175
  135.    End
  136.    Begin CommandButton TestStringChange 
  137.       Caption         =   "Adds'!'to""Hello"""
  138.       Height          =   375
  139.       Left            =   2640
  140.       TabIndex        =   9
  141.       Top             =   2160
  142.       Width           =   1575
  143.    End
  144.    Begin CommandButton TestVBString 
  145.       Caption         =   "ReceivesVBString(""String to DLL"")"
  146.       Height          =   375
  147.       Left            =   240
  148.       TabIndex        =   11
  149.       Top             =   2760
  150.       Width           =   3375
  151.    End
  152.    Begin CommandButton TestUserType 
  153.       Caption         =   "ReceivesUserType(1,2,3,4)"
  154.       Height          =   375
  155.       Left            =   3720
  156.       TabIndex        =   14
  157.       Top             =   2760
  158.       Width           =   3495
  159.    End
  160.    Begin CommandButton TestVBStringChange 
  161.       Caption         =   "ChangesVBString(""Short"")"
  162.       Height          =   375
  163.       Left            =   240
  164.       TabIndex        =   12
  165.       Top             =   3240
  166.       Width           =   3375
  167.    End
  168.    Begin CommandButton TestAddUserString 
  169.       Caption         =   "AddUserString"
  170.       Height          =   375
  171.       Left            =   3720
  172.       TabIndex        =   18
  173.       Top             =   3240
  174.       Width           =   1695
  175.    End
  176.    Begin CommandButton ReceivesIntArray 
  177.       Caption         =   "Int Array"
  178.       Height          =   375
  179.       Left            =   5520
  180.       TabIndex        =   17
  181.       Top             =   3240
  182.       Width           =   1695
  183.    End
  184.    Begin CommandButton ReturnVBString 
  185.       Caption         =   "ReturnsVBString()"
  186.       Height          =   375
  187.       Left            =   240
  188.       TabIndex        =   13
  189.       Top             =   3720
  190.       Width           =   3375
  191.    End
  192. End
  193. ' DLL parameter test program
  194. ' Copyright (c) 1992, by Desaware
  195. ' All rights reserved
  196. '
  197. '
  198. ' This program is used to test the dllparam.dll dynamic
  199. ' link library.
  200.  
  201. Sub Command1_Click ()
  202.     ReDim x(5) As Integer
  203.     Dim y%
  204.     x(0) = 0
  205.     x(1) = 1
  206.     x(2) = 2
  207.     x(3) = 3
  208.     x(4) = 4
  209.     y% = ReceivesVBArray(x())
  210. End Sub
  211.  
  212. Sub Command2_Click ()
  213.     Dim v As Variant
  214.     Dim res%
  215.     v = "hello"
  216.     res% = ReceivesVariantByVal(v)
  217. End Sub
  218.  
  219. Sub Command3_Click ()
  220.     Dim v As Variant
  221.     Dim res%
  222.     v = "hello"
  223.     v = ReceivesVariant(v)
  224.     MsgBox "V is " + v
  225. End Sub
  226.  
  227. ' This is a test of passing a pointer to a numeric array
  228. ' Note the unique DLL call
  229. '
  230. Sub ReceivesIntArray_Click ()
  231.     ReDim x(4) As Integer
  232.     Dim u As UserType
  233.     x(0) = 1
  234.     x(1) = 3
  235.     x(2) = 9
  236.     x(3) = 81
  237.     ' Pass a pointer to the first element of the array.
  238.     ' The DLL has no way of knowing how long the array is
  239.     ' unless you define a length parameter for the function.
  240.     ReceivesIntArray x(0)
  241.  
  242.     u.e(0) = 1
  243.     u.e(1) = 2
  244.     u.e(2) = 3
  245.     u.e(3) = 4
  246.     ReceivesIntArray (u.e(0))
  247. End Sub
  248.  
  249. ' A DLL function returning a Visual Basic String
  250. Sub ReturnVBString_Click ()
  251.     a$ = ReturnsVBString()
  252.     MsgBox a$, 0, "ReturnsVBString"
  253. End Sub
  254.  
  255. '   Show how to access strings inside user defined types
  256. Sub TestAddUserString_Click ()
  257.     Dim u As UserType
  258.     ' Note - this is call by reference, the DLL can change
  259.     ' the value of u
  260.     u.s = "orignal string"
  261.     AddUserString u
  262.     MsgBox u.s, 0, "String in usertype changed"
  263.  
  264. End Sub
  265.  
  266. ' Passing controls and forms as parameters
  267. Sub TestControl_Click ()
  268.     hctl% = GetControlHwnd(TestControl)
  269.     hfrm% = GetFormHwnd(dllparam)
  270.     MsgBox "This control hwnd is " + Str$(hctl%) + ", the form hwnd is " + Str$(hfrm%), 0, "Get Hwnds"
  271. End Sub
  272.  
  273. ' Passing currency by reference
  274. Sub TestCurrencyByref_Click ()
  275.     Dim c@
  276.     c@ = 1.23
  277.     AddPennyToCurrency c@
  278.     MsgBox Str$(c@), 0, "AddPennyToCurrency"
  279. End Sub
  280.  
  281. ' Passing currency by value and returning currency
  282. Sub TestCurrencyByval_Click ()
  283.     Dim c@
  284.     c = 1.2345
  285.     c = ReceivesCurrency(c)
  286. End Sub
  287.  
  288. ' Passing doubles by reference
  289. Sub TestDoubleByref_Click ()
  290.     d# = 3.145
  291.     Add5ToDouble d#
  292.     MsgBox Str$(d#), 0, "Add5ToDouble"
  293.  
  294. End Sub
  295.  
  296. ' Passing doubles by value and returning doubles
  297. Sub TestDoubleByval_Click ()
  298.     d# = ReceivesDouble(3.145)
  299. End Sub
  300.  
  301. ' Passing integers by reference
  302. Sub TestIntByref_Click ()
  303.     x% = 5
  304.     Add5ToInteger x%
  305.     MsgBox Str$(x%), 0, "Add5ToInteger"
  306. End Sub
  307.  
  308. ' Passing integers by value and returning integers
  309. Sub TestIntByval_Click ()
  310.     x% = ReceivesInteger(5)
  311. End Sub
  312.  
  313. ' Passing longs by reference
  314. Sub TestLongByref_Click ()
  315.     y& = 6
  316.     Add5ToLong y&
  317.     MsgBox Str$(y&), 0, "Add5ToLong"
  318.  
  319. End Sub
  320.  
  321. ' Passing longs by value and returning longs
  322. Sub TestLongByval_Click ()
  323.     y& = ReceivesLong(6)
  324. End Sub
  325.  
  326. ' Passing singles by reference
  327. Sub TestSingleByref_Click ()
  328.     f! = 1.59
  329.     Add5ToSingle f!
  330.     MsgBox Str$(f!), 0, "Add5ToSingle"
  331.  
  332. End Sub
  333.  
  334. ' Passing singles by value and returning singles
  335. Sub TestSingleByval_Click ()
  336.     f! = ReceivesSingle(1.59)
  337. End Sub
  338.  
  339. ' Passing strings (null terminated)
  340. ' Always by reference
  341. Sub TestString_Click ()
  342.     ReceivesString "Hello"
  343. End Sub
  344.  
  345. ' Passing and modifying strings (null terminated)
  346. ' Always by reference
  347. Sub TestStringChange_Click ()
  348.     ' Null terminated string is passed to the routine
  349.     ' x$ must be preinitialized to the maximum length.
  350.     ' The DLL may change the contents of the string, but
  351.     ' must never go past the null terminator
  352.     x$ = "Hello"
  353.     ChangesString x$
  354.     MsgBox x$, 0, "ChangesString"
  355. End Sub
  356.  
  357. ' Passing user defined types
  358. ' Always by reference
  359. Sub TestUserType_Click ()
  360.     Dim u As UserType
  361.     u.a = 1
  362.     u.b = 2
  363.     u.c = 3
  364.     u.d = 4
  365.     u.e(0) = 5
  366.     u.e(1) = 6
  367.     u.e(2) = 7
  368.     u.e(3) = 8
  369.     ' Note - this is call by reference, the DLL can change
  370.     ' the value of u
  371.     ReceivesUserType u
  372. End Sub
  373.  
  374. ' Passing Visual Basic strings
  375. Sub TestVBString_Click ()
  376.     ReceivesVBString "String to DLL"
  377. End Sub
  378.  
  379. ' Passing and modifying Visual Basic strings
  380. ' Note - no length restrictions apply
  381. Sub TestVBStringChange_Click ()
  382.     a$ = "Short"
  383.     ChangesVBString a$
  384.     MsgBox a$, 0, "ChangesVBString"
  385. End Sub
  386.  
  387.