home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxdemo.zip / THREADS.$$$ / WINDOW2.VRX < prev    next >
Text File  |  1993-10-22  |  3KB  |  138 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         Fini
  67. */
  68. Fini:
  69.     window = VRWindow()
  70.     call VRSet window, "Visible", 0
  71.     drop window
  72.  
  73.     my_id = VRMethod( "Application", "GetThreadId" )
  74.     call VRMethod "Application", "Post", parent_id,,
  75.                   "call DeleteThread" my_id
  76.     return 0
  77.  
  78. /*:VRX         Halt
  79. */
  80. Halt:
  81.     call NotifyParent
  82.     call Quit
  83.     signal _VREHalt
  84. return
  85.  
  86. /*:VRX         Init
  87. */
  88. Init:
  89.     window = VRWindow()
  90.  
  91.     my_id = VRMethod( "Application", "GetThreadId" )
  92.     call VRSet window, "Caption", "Thread" my_id
  93.  
  94.     call VRMethod window, 'CenterWindow'
  95.     call VRSet window, "Visible", 1
  96.     call VRMethod window, "Activate"
  97.  
  98.     call VRMethod "entryField", "SetFocus"
  99.     drop window
  100.  
  101.     parent_id = InitArgs.1
  102.  
  103.     call VRMethod 'Application', 'Post', parent_id, 'call UpdateThreadList'
  104.     return
  105. /*:VRX         NotifyParent
  106. */
  107. NotifyParent:
  108.     tid = VRMethod( "Application", "GetThreadID" )
  109.     call VRMethod "Application", "Post",,
  110.          "call DeleteThread " tid
  111. return
  112.  
  113. /*:VRX         PB_1_Click
  114. */
  115. PB_1_Click:
  116.     text = VRGet( "EntryField", "Value" )
  117.     call VRMethod "Application", "Post", parent_id,,
  118.             "call ShowMessage", "message", text
  119.     call VRSet "EntryField", "Value", ""
  120.     call VRMethod "EntryField", "SetFocus"
  121. return
  122.  
  123. /*:VRX         Quit
  124. */
  125. Quit:
  126.     window = VRWindow()
  127.     call VRSet window, "Shutdown", 1
  128.     drop window
  129. return
  130.  
  131. /*:VRX         Window2_Close
  132. */
  133. Window2_Close:
  134.     call NotifyParent
  135.     call Quit
  136. return
  137.  
  138.