home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 035 / vxrxs21a.zip / macros / vxrez / editres.vrx < prev    next >
Text File  |  1994-10-31  |  8KB  |  359 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.  
  31.     if( ProjSaved( parent ) = 0 )then signal _VRELeaveMain
  32.  
  33.     _VREPrimaryWindowPath = ,
  34.         VRParseFileName( spec, "dpn" ) || ".VRW"
  35.     _VREPrimaryWindow = ,
  36.         VRLoad( parent, _VREPrimaryWindowPath )
  37.     drop parent spec
  38.     if( _VREPrimaryWindow == "" )then do
  39.         call VRMessage "", "Cannot load window:" VRError(), ,
  40.             "Error!"
  41.         _VREReturnValue = 32000
  42.         signal _VRELeaveMain
  43.     end
  44.  
  45. /*  Process events
  46. */
  47.     call Init
  48.     signal on halt
  49.     do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
  50.         _VREEvent = VREvent()
  51.         interpret _VREEvent
  52.     end
  53. _VREHalt:
  54.     _VREReturnValue = Fini()
  55.     call VRDestroy _VREPrimaryWindow
  56. _VRELeaveMain:
  57.     call VRFini
  58. exit _VREReturnValue
  59.  
  60. VRLoadSecondary: procedure
  61.     name = arg( 1 )
  62.  
  63.     window = VRLoad( VRWindow(), VRWindowPath(), name )
  64.     call VRMethod window, "CenterWindow"
  65.     call VRSet window, "Visible", 1
  66.     call VRMethod window, "Activate"
  67. return window
  68.  
  69. /*:VRX         AboutMenu_Click
  70. */
  71. AboutMenu_Click:
  72.     path = VREPath() || "MACROS\VXREZ\about.vrm"
  73.     call VRMacro path, VRWindow()
  74. return
  75.  
  76. /*:VRX         BeginWait
  77. */
  78. BeginWait:
  79.     window = VRWindow()
  80.     call VRSet window, 'StatusText', arg(1)
  81.     call VRSet window, 'Pointer', 'Wait'
  82. return
  83.  
  84. /*:VRX         CompileFile
  85. */
  86. CompileFile:
  87.     call BeginWait 'Compiling file...'
  88.     address cmd
  89.     old = directory()
  90.     dir = VRParseFileName( RCPath, 'dp' )
  91.     call directory dir
  92.  
  93.     'rc -r' RCPath '>__out'
  94.  
  95.     call EndWait
  96.  
  97.     if( rc \= 0 )then do
  98.         stem.1 = 'Compilation error:'
  99.         stem.2 = ''
  100.         i = 2
  101.         do while lines( '__out' )
  102.             i = i + 1
  103.             stem.i = linein( '__out' )
  104.         end
  105.         call stream '__out', 'c', 'close'
  106.         stem.0 = i
  107.         call VRMessageStem VRWindow(), 'stem.', 'Edit Resources', 'none'
  108.     end
  109.  
  110.     call VRDeleteFile '__old'
  111.     call directory old
  112. return
  113.  
  114. /*:VRX         CompileMenu_Click
  115. */
  116. CompileMenu_Click:
  117.     call SaveFile
  118.     call CompileFile
  119. return
  120.  
  121. /*:VRX         CopyMenu_Click
  122. */
  123. CopyMenu_Click:
  124.     call VRMethod 'MLE', 'Copy'
  125. return
  126.  
  127. /*:VRX         CutMenu_Click
  128. */
  129. CutMenu_Click:
  130.     call VRMethod 'MLE', 'Cut'
  131. return
  132.  
  133. /*:VRX         DeleteMenu_Click
  134. */
  135. DeleteMenu_Click:
  136.     call VRMethod 'Application', 'PostKeyString', 'MLE', '{Del}'
  137. return
  138.  
  139. /*:VRX         EndWait
  140. */
  141. EndWait:
  142.     window = VRWindow()
  143.     call VRSet window, 'StatusText', arg(1)
  144.     call VRSet window, 'Pointer', '<Default>'
  145. return
  146.  
  147. /*:VRX         Fini
  148. */
  149. Fini:
  150.     window = VRWindow()
  151.     call VRSet window, "Visible", 0
  152.     drop window
  153. return 0
  154.  
  155. /*:VRX         Halt
  156. */
  157. Halt:
  158.     signal _VREHalt
  159. return
  160.  
  161. /*:VRX         IconMenu_Click
  162. */
  163. IconMenu_Click:
  164.     dir = VRParseFileName( RCPath, 'DP' )
  165.     old = directory()
  166.     call directory dir
  167.     'start /f iconedit'
  168.     call directory old
  169. return
  170.  
  171. /*:VRX         ImportFile
  172. */
  173. ImportFile:
  174.     if( arg() = 0 )then do
  175.         path = VRParseFileName( RCPath, "DP" ) || '\*.*'
  176.         do while( path \= '' )
  177.             path = VRFileDialog( VRWindow(), 'Import file', 'o', path )
  178.             if( path \= '' & VRFileExists( path ) = 1 )then leave
  179.         end
  180.     end; else do
  181.         path = arg( 1 )
  182.     end
  183.     if( path = '' )then return
  184.     
  185.     event = VRGet( 'MLE', 'Change' )
  186.     call VRSet 'MLE', 'Change', ''
  187.  
  188.     call BeginWait "Loading file..."
  189.  
  190.     value = charin( path, 1, chars( path ) )
  191.     if( length( value ) > 0 )then do
  192.         call VRMethod 'MLE', 'Insert', value
  193.     end
  194.     call stream path, 'c', 'close'
  195.  
  196.     call EndWait
  197.  
  198.     call VRSet 'MLE', 'Change', event
  199.     MLEChanged = 1
  200. return
  201.  
  202. /*:VRX         ImportMenu_Click
  203. */
  204. ImportMenu_Click:
  205.     call ImportFile
  206. return
  207.  
  208. /*:VRX         Init
  209. */
  210. Init:
  211.     RCPath = VRParseFileName( ProjectPath, "DPN" ) || '.RC'
  212.     MLEChanged = 0
  213.  
  214.     window = VRWindow()
  215.  
  216. /*
  217.     call VRSet window, 'Caption', 'Editing RC File' VRParseFileName( RCPath, "NE" )
  218. */
  219.  
  220.     call VRSet 'MLE', 'Value', ''
  221.     call ImportFile RCPath
  222.     MLEChanged = 0
  223.  
  224.     call VRMethod window, "CenterWindow"
  225.     call VRSet window, "Visible", 1
  226.     call VRMethod window, "Activate"
  227.     drop window
  228. return
  229.  
  230. /*:VRX         InsertResource
  231. */
  232. InsertResource: 
  233.     path = VREPath() || "MACROS\VXREZ\resource.vrm"
  234.     call VRMacro path, VRWindow(), arg(1)
  235.     insert = result
  236.     if( insert \= '' )then do
  237.         call VRMethod 'MLE', 'Insert', insert || '0d'x
  238.     end
  239. return
  240.  
  241. /*:VRX         MLE_Change
  242. */
  243. MLE_Change:
  244.     MLEChanged = 1
  245. return
  246.  
  247. /*:VRX         MLE_ContextMenu
  248. */
  249. MLE_ContextMenu:
  250.     call VRMethod 'EditMenu', 'Popup'
  251. return
  252.  
  253. /*:VRX         OS2Menu_Click
  254. */
  255. OS2Menu_Click:
  256.     dir = VRParseFileName( RCPath, 'PD' )
  257.     old = directory()
  258.     call directory dir
  259.     'start /k /f'
  260.     call directory old
  261. return
  262.  
  263. /*:VRX         PasteMenu_Click
  264. */
  265. PasteMenu_Click:
  266.     call VRMethod 'MLE', 'Paste'
  267. return
  268.  
  269. /*:VRX         ProjSaved
  270. */
  271. ProjSaved:
  272.     parse arg parent
  273.     ok = 1
  274.     ProjectPath = VREProjPermPath()
  275.     if( pos( '\', ProjectPath ) = 0 )then do
  276.         msg = 'Please save the project to disk before editing any resources.'
  277.         call VRMessage parent, msg, 'Edit Resources'
  278.         ok = 0
  279.     end
  280. return ok
  281.  
  282. /*:VRX         Quit
  283. */
  284. Quit:
  285.     window = VRWindow()
  286.     call VRSet window, "Shutdown", 1
  287.     drop window
  288. return
  289.  
  290. /*:VRX         ResourceMenu_Click
  291. */
  292. ResourceMenu_Click:
  293.     call InsertResource
  294. return
  295.  
  296. /*:VRX         SaveFile
  297. */
  298. SaveFile:
  299.     call BeginWait 'Saving file...'
  300.     call VRDeleteFile RCPath
  301.     value = VRGet( 'MLE', 'Value' )
  302.     if( length( value ) \= 0 )then do
  303.         last = right( value, 1 )
  304.         if( last \= '0a'x & last \= '0d'x )then do
  305.             value = value || '0d'x
  306.         end
  307.     end
  308.     call charout RCPath, value, 1
  309.     call stream RCPath, 'c', 'close'
  310.     MLEChanged = 0
  311.     call EndWait
  312. return
  313.  
  314. /*:VRX         SaveMenu_Click
  315. */
  316. SaveMenu_Click:
  317.     call SaveFile
  318. return
  319.  
  320. /*:VRX         UndoMenu_Click
  321. */
  322. UndoMenu_Click:
  323.     call VRMethod 'MLE', 'Undo'
  324. return
  325.  
  326. /*:VRX         Window1_Close
  327. */
  328. Window1_Close:
  329.     if( MLEChanged = 1 )then do
  330.         buttons.0 = 3
  331.         buttons.1 = '~Save'
  332.         buttons.2 = '~Discard'
  333.         buttons.3 = '~Cancel'
  334.         default   = 1
  335.         esc       = 3
  336.         msg = 'File has changed.  Do you wish to save it before quitting?'
  337.         response  = VRMessage( VRWindow(), msg, ,
  338.                                'Edit Resources', 'q', ,
  339.                                'buttons.', default, esc )
  340.         if( response = 3 )then return
  341.         if( response = 1 )then call SaveFile        
  342.     end
  343.     call Quit
  344. return
  345.  
  346. /*:VRX         Window1_DragDrop
  347. */
  348. Window1_DragDrop: 
  349.     file = VRInfo( "SourceFile" )
  350.     call InsertResource file
  351. return
  352.  
  353. /*:VRX         Window1_Help
  354. */
  355. Window1_Help: 
  356.     address cmd 'view progguid.inf Adding resources to your project'
  357. return
  358.  
  359.