home *** CD-ROM | disk | FTP | other *** search
/ Total C++ 2 / TOTALCTWO.iso / vfp5.0 / vfp / samples / tastrade / progs / main.prg < prev    next >
Encoding:
Text File  |  1996-08-21  |  2.5 KB  |  90 lines

  1. *-- (c) Microsoft Corporation 1995
  2.  
  3. #INCLUDE "INCLUDE\TASTRADE.H"
  4.  
  5. *-- DECLARE DLL statements for reading/writing to private INI files
  6. DECLARE INTEGER GetPrivateProfileString IN Win32API  AS GetPrivStr ;
  7.   String cSection, String cKey, String cDefault, String @cBuffer, ;
  8.   Integer nBufferSize, String cINIFile
  9.  
  10. DECLARE INTEGER WritePrivateProfileString IN Win32API AS WritePrivStr ;
  11.   String cSection, String cKey, String cValue, String cINIFile
  12.  
  13. *-- DECLARE DLL statements for reading/writing to system registry
  14. DECLARE Integer RegOpenKeyEx IN Win32API ;
  15.   Integer nKey, String @cSubKey, Integer nReserved,;
  16.   Integer nAccessMask, Integer @nResult
  17.  
  18. DECLARE Integer RegQueryValueEx IN Win32API ;
  19.   Integer nKey, String cValueName, Integer nReserved,;
  20.   Integer @nType, String @cBuffer, Integer @nBufferSize
  21.  
  22. DECLARE Integer RegCloseKey IN Win32API ;
  23.   Integer nKey
  24.  
  25. *-- DECLARE DLL statement for Windows 3.1 API function GetProfileString
  26. DECLARE INTEGER GetProfileString IN Win32API AS GetProStr ;
  27.   String cSection, String cKey, String cDefault, ;
  28.   String @cBuffer, Integer nBufferSize
  29.  
  30. CLEAR
  31.  
  32. *-- Ensure the project manager is closed, or we may run into
  33. *-- conflicts when trying to KEYBOARD a hot-key
  34. DEACTIVATE WINDOW "Project Manager"
  35.  
  36. *-- All public vars will be released as soon as the application
  37. *-- object is created. 
  38.  
  39. IF SET('TALK') = 'ON'
  40.   SET TALK OFF
  41.   PUBLIC gcOldTalk
  42.   gcOldTalk = 'ON'
  43. ELSE
  44.   PUBLIC gcOldTalk
  45.   gcOldTalk = 'OFF'
  46. ENDIF
  47.  
  48. PUBLIC gcOldDir, gcOldPath, gcOldClassLib, gcOldEscape, gTTrade
  49. gcOldEscape   = SET('ESCAPE')
  50. gcOldDir       = FULLPATH(CURDIR())
  51. gcOldPath     = SET('PATH')
  52. gcOldClassLib = SET('CLASSLIB')
  53. gTTrade = .T.
  54.  
  55. *-- Set up the path so we can instantiate the application object
  56. IF SetPath()
  57.   PUBLIC oApp
  58.   oApp = CREATEOBJECT("TasTrade")
  59.   IF TYPE('oApp') = "O"
  60.     *-- Release all public vars, since their values were
  61.     *-- picked up by the Environment class
  62.     RELEASE gcOldDir, gcOldPath, gcOldClassLib, gcOldTalk, gcOldEscape
  63.     oApp.Do()
  64.   ENDIF
  65. ENDIF
  66.  
  67. CLEAR DLLS
  68. RELEASE ALL EXTENDED
  69. CLEAR ALL
  70.  
  71. FUNCTION SetPath()
  72.   LOCAL lcSys16, ;
  73.         lcProgram
  74.  
  75.   lcSys16 = SYS(16)
  76.   lcProgram = SUBSTR(lcSys16, AT(":", lcSys16) - 1)
  77.  
  78.   CD LEFT(lcProgram, RAT("\", lcProgram))
  79.   *-- If we are running MAIN.PRG directly, then
  80.   *-- CD up to the parent directory
  81.   IF RIGHT(lcProgram, 3) = "FXP"
  82.     CD ..
  83.   ENDIF
  84.   SET PATH TO PROGS, FORMS, LIBS, ;
  85.         MENUS, DATA, OTHER, ;
  86.         REPORTS, INCLUDE, HELP, ;
  87.         BITMAPS
  88.   SET CLASSLIB TO MAIN, TSGEN
  89. ENDFUNC
  90.