home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxdemo.zip / WINCTRL.$$$ / WINDOW1.VRX < prev    next >
Text File  |  1993-09-06  |  5KB  |  228 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         ApplyMethod
  67. */
  68. ApplyMethod: arg method
  69.     ok = VRMethod( "LB_1", "GetSelectedStringList", "window." )
  70.     if ok = 1 then do
  71.         do i = 1 to window.0
  72.             w = word( window.i, 1 )
  73.             call vrmethod w, method
  74.         end
  75.     end
  76. return
  77.  
  78. /*:VRX         Fini
  79. */
  80. Fini:
  81.     window = VRWindow()
  82.     call VRSet window, "Visible", 0
  83.     drop window
  84. return 0
  85.  
  86. /*:VRX         Halt
  87. */
  88. Halt:
  89.     signal _VREHalt
  90. return
  91.  
  92. /*:VRX         Init
  93. */
  94. Init:
  95.     window = VRWindow()
  96.     call VRMethod window, "CenterWindow"
  97.     call VRSet window, "Visible", 1
  98.     call VRMethod window, "Activate"
  99.     call Refresh
  100.     drop window
  101. return
  102.  
  103. /*:VRX         Menu2_Click
  104. */
  105. Menu2_Click:
  106.     call VRLoadSecondary "SW_1"
  107. return
  108.  
  109. /*:VRX         Menu4_Click
  110. */
  111. Menu4_Click:
  112.     call Shake
  113. return
  114.  
  115. /*:VRX         Menu5_Click
  116. */
  117. Menu5_Click:
  118.     call ApplyMethod "Minimize"
  119.  
  120. return
  121.  
  122. /*:VRX         Menu6_Click
  123. */
  124. Menu6_Click:
  125.     call ApplyMethod "Maximize"
  126. return
  127.  
  128. /*:VRX         Menu7_Click
  129. */
  130. Menu7_Click:
  131.     call ApplyMethod "Restore"
  132.  
  133. return
  134.  
  135. /*:VRX         PB_1_Click
  136. */
  137. PB_1_Click:
  138.     call refresh
  139. return
  140.  
  141. /*:VRX         PB_2_Click
  142. */
  143. PB_2_Click:
  144.     call ApplyMethod "Minimize"
  145. return
  146.  
  147. /*:VRX         PB_3_Click
  148. */
  149. PB_3_Click:
  150.     call ApplyMethod "Restore"
  151.     return
  152.  
  153. /*:VRX         PB_4_Click
  154. */
  155. PB_4_Click:
  156.     call Shake
  157. return
  158.  
  159. /*:VRX         PB_5_Click
  160. */
  161. PB_5_Click:
  162.     call VRDestroy "SW_1"
  163. return
  164.  
  165. /*:VRX         Quit
  166. */
  167. Quit:
  168.     window = VRWindow()
  169.     call VRSet window, "Shutdown", 1
  170.     drop window
  171. return
  172.  
  173. /*:VRX         Refresh
  174. */
  175. Refresh:
  176.     call vrset "LB_1", "Painting", 0
  177.     call vrmethod "LB_1", "Clear"
  178.     ok = vrmethod( "application", "ListWindows", "window." )
  179.     if ok = 1 then do
  180.         do i = 1 to window.0
  181.             w = word( window.i, 1 )
  182.             if vrget( w, "visible" ) = 1 then do
  183.                 x = w "---" vrget( w, "Caption" )
  184.                 call vrmethod "LB_1", "AddString", x
  185.             end
  186.         end
  187.     end
  188.     call vrset "LB_1", "Painting", 1       
  189. return
  190.  
  191. /*:VRX         Shake
  192. */
  193. Shake:
  194.     delta = 50
  195.     ok = VRMethod( "LB_1", "GetSelectedStringList", "window." )
  196.     if ok = 1 then do
  197.         do i = 1 to window.0
  198.             w = word( window.i, 1 )
  199.             left = vrget( w, "Left" )
  200.             top = vrget( w, "Top" )
  201.  
  202.             call vrset w, "Top", top - delta
  203.             call vrset w, "Top", top + 2 * delta
  204.             call vrset w, "Top", top 
  205.  
  206.             call vrset w, "Left", left - delta
  207.             call vrset w, "Left", left + 2 * delta
  208.             call vrset w, "Left", left 
  209.  
  210.         end
  211.     end
  212.  
  213. return
  214.  
  215. /*:VRX         SW_1_Close
  216. */
  217. SW_1_Close:
  218.     window = VRInfo( "Object" )
  219.     call VRDestroy window
  220.     drop window
  221. return
  222. /*:VRX         Window1_Close
  223. */
  224. Window1_Close:
  225.     call Quit
  226. return
  227.  
  228.