home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxcliser.zip / VXREXX.3 / SAMPLES / THREADS / CHILD.VRX next >
Text File  |  1994-12-23  |  3KB  |  149 lines

  1. /*:VRX         Main
  2. */
  3. /*  Main
  4. */
  5. Main:
  6. /*  Process the arguments.
  7.     Get the parent window.
  8. */
  9.     parse source . calledAs .
  10.     parent = ""
  11.     argCount = arg()
  12.     argOff = 0
  13.     if( calledAs \= "COMMAND" )then do
  14.         if argCount >= 1 then do
  15.             parent = arg(1)
  16.             argCount = argCount - 1
  17.             argOff = 1
  18.         end
  19.     end
  20.     InitArgs.0 = argCount
  21.     if( argCount > 0 )then do i = 1 to argCount
  22.         InitArgs.i = arg( i + argOff )
  23.     end
  24.     drop calledAs argCount argOff
  25.  
  26. /*  Load the windows
  27. */
  28.     call VRInit
  29.     parse source . . spec
  30.     _VREPrimaryWindowPath = ,
  31.         VRParseFileName( spec, "dpn" ) || ".VRW"
  32.     _VREPrimaryWindow = ,
  33.         VRLoad( parent, _VREPrimaryWindowPath )
  34.     drop parent spec
  35.     if( _VREPrimaryWindow == "" )then do
  36.         call VRMessage "", "Cannot load window:" VRError(), ,
  37.             "Error!"
  38.         _VREReturnValue = 32000
  39.         signal _VRELeaveMain
  40.     end
  41.  
  42. /*  Process events
  43. */
  44.     call Init
  45.     signal on halt
  46.     do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
  47.         _VREEvent = VREvent()
  48.         interpret _VREEvent
  49.     end
  50. _VREHalt:
  51.     _VREReturnValue = Fini()
  52.     call VRDestroy _VREPrimaryWindow
  53. _VRELeaveMain:
  54.     call VRFini
  55. exit _VREReturnValue
  56.  
  57. VRLoadSecondary: procedure
  58.     name = arg( 1 )
  59.  
  60.     window = VRLoad( VRWindow(), VRWindowPath(), name )
  61.     call VRMethod window, "CenterWindow"
  62.     call VRSet window, "Visible", 1
  63.     call VRMethod window, "Activate"
  64. return window
  65.  
  66. /*:VRX         EF_Text_Change
  67. */
  68. EF_Text_Change: 
  69.     /* Only allow the sending of valid messages.
  70.     */
  71.  
  72.     value = VRGet( "EF_Text", "Value" )
  73.     if( LENGTH(value) > 0 ) then do
  74.         call VRSet "PB_Send", "Enabled", 1
  75.     end
  76.     else do
  77.         call VRSet "PB_Send", "Enabled", 0
  78.     end
  79. return
  80.  
  81. /*:VRX         Fini
  82. */
  83. Fini: procedure
  84.     /* Destroy the window
  85.     */
  86.  
  87.     window = VRWindow()
  88.     call VRSet window, "Visible", 0
  89.     tid = VRMethod( "Application", "GetThreadId" )
  90.     call VRMethod "Application", "PostQueue", 0, 0, 'call VRMethod "LB_Threads", "DeleteString",' tid
  91. return 0
  92.  
  93. /*:VRX         Halt
  94. */
  95. Halt:
  96.     signal _VREHalt
  97. return
  98.  
  99. /*:VRX         Init
  100. */
  101. Init: procedure
  102.     /* Create the window
  103.     */
  104.  
  105.     window = VRWindow()
  106.     call VRMethod window, 'CenterWindow'
  107.     call VRSet window, "Visible", 1
  108.     call VRMethod window, "Activate" 
  109.  
  110.     /* Get and display the thread ID
  111.     */
  112.  
  113.     tid = VRMethod( "Application", "GetThreadId" )
  114.     call VRSet window, "Caption", "Thread" tid
  115.     call VRMethod "EF_Text", "SetFocus"
  116.     call VRMethod "Application", "PostQueue", 0, 0, "call Update"
  117.  
  118. return
  119. /*:VRX         PB_Send_Click
  120. */
  121. PB_Send_Click:
  122.     /* Send the message to the parent
  123.     */
  124.  
  125.     text = VRGet( "EF_Text", "Value" )
  126.     call VRMethod "Application", "PostQueue", 0, 0, "call ShowMessage", "Message", text
  127.     call VRSet "EF_Text", "Value", ""
  128.     call VRMethod "EF_Text", "SetFocus"
  129.     drop text
  130. return
  131.  
  132. /*:VRX         Quit
  133. */
  134. Quit:
  135.     /* Program execution will continue in the 'Threads' file.
  136.     */
  137.  
  138.     window = VRWindow()
  139.     call VRSet window, "Shutdown", 1
  140.     drop window
  141. return
  142.  
  143. /*:VRX         Window1_Close
  144. */
  145. Window1_Close:
  146.     call Quit
  147. return
  148.  
  149.