LuaEdit.dpr 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. ////////////////////////////////////////////////////////////////
  2. // IMPORTANT NOTICE:
  3. // Do not include ShareMem unit in the project. Faulting to
  4. // such thing would cause an EInvalidPointer error when
  5. // LuaEdit will close.
  6. ////////////////////////////////////////////////////////////////
  7. program LuaEdit;
  8. uses
  9. Forms,
  10. Dialogs,
  11. SysUtils,
  12. Classes,
  13. IniFiles,
  14. Windows,
  15. Messages,
  16. JvDockControlForm,
  17. JvComponent,
  18. JvDockVIDStyle,
  19. JvDockVSNetStyle,
  20. JvAppRegistryStorage,
  21. About in 'About.pas' {frmAbout},
  22. GoToLine in 'GoToLine.pas' {frmGotoLine},
  23. Main in 'Main.pas' {frmLuaEditMain},
  24. ProjectTree in 'ProjectTree.pas' {frmProjectTree},
  25. Replace in 'Replace.pas' {frmReplace},
  26. ReplaceQuerry in 'ReplaceQuerry.pas' {frmReplaceQuerry},
  27. Search in 'Search.pas' {frmSearch},
  28. Stack in 'Stack.pas' {frmStack},
  29. Splash in 'Splash.pas' {frmSplash},
  30. Watch in 'Watch.pas' {frmWatch},
  31. FunctionList in 'FunctionList.pas' {frmFunctionList},
  32. AddToPrj in 'AddToPrj.pas' {frmAddToPrj},
  33. ErrorLookup in 'ErrorLookup.pas' {frmErrorLookup},
  34. LuaStack in 'LuaStack.pas' {frmLuaStack},
  35. PrintSetup in 'PrintSetup.pas' {frmPrintSetup},
  36. PrjSettings in 'PrjSettings.pas' {frmPrjOptions},
  37. Contributors in 'Contributors.pas' {frmContributors},
  38. LuaUtils in 'LuaCore\LuaUtils.pas',
  39. Breakpoints in 'Breakpoints.pas' {frmBreakpoints},
  40. RegSetFileType in 'RegSetFileType.pas',
  41. LuaLocals in 'LuaLocals.pas' {frmLuaLocals},
  42. LuaEditMessages in 'LuaEditMessages.pas' {frmLuaEditMessages},
  43. AddBreakpoint in 'AddBreakpoint.pas' {frmAddBreakpoint},
  44. LuaGlobals in 'LuaGlobals.pas' {frmLuaGlobals},
  45. EditorSettings in 'EditorSettings.pas' {frmEditorSettings},
  46. ExSaveExit in 'ExSaveExit.pas' {frmExSaveExit},
  47. AsciiTable in 'AsciiTable.pas' {frmAsciiTable},
  48. ReadOnlyMsgBox in 'ReadOnlyMsgBox.pas' {frmReadOnlyMsgBox},
  49. Rings in 'Rings.pas' {frmRings},
  50. SearchPath in 'SearchPath.pas' {frmSearchPath},
  51. InternalBrowser in 'InternalBrowser.pas' {frmInternalBrowser},
  52. FindInFiles in 'FindInFiles.pas' {frmFindInFiles},
  53. SIFReport in 'SIFReport.pas' {frmSIFReport},
  54. FindWindow1 in 'FindWindow1.pas' {frmFindWindow1},
  55. FindWindow2 in 'FindWindow2.pas' {frmFindWindow2},
  56. Misc in 'Misc.pas',
  57. UploadFiles in 'UploadFiles.pas' {frmUploadFiles},
  58. Profiler in 'Profiler.pas' {frmProfiler},
  59. PrecisionTimer in 'PrecisionTimer.pas',
  60. ComponentList in 'ComponentList.pas' {frmComponentList},
  61. GUID in 'GUID.pas' {frmGUID},
  62. LEMacros in 'LEMacros.pas',
  63. MacroManager in 'MacroManager.pas' {frmMacroManager},
  64. GUIInspector in 'GUIInspector.pas' {frmGUIInspector},
  65. GUIDesigner in 'GUIDesigner.pas' {GUIForm1},
  66. GUIControls in 'GUIControls.pas' {frmGUIControls},
  67. GUIFormType in 'GUIFormType.pas' {frmGUIFormType},
  68. ConvertPath in 'ConvertPath.pas' {frmConvertPath},
  69. LuaConsole in 'LuaConsole.pas' {frmLuaConsole};
  70. {$R *.res}
  71. function GetRunningProcesses(): PChar; cdecl; external 'LuaEditSys.dll';
  72. var
  73. i, x: Integer;
  74. hChild, hParent: HWND;
  75. FileName: String;
  76. pFiles: TStringList;
  77. copyDataStruct: TCopyDataStruct;
  78. // This function look for another instance of LuaEdit
  79. function CheckAppInstance(): Boolean;
  80. var
  81. pProcesses: TStringList;
  82. i, AppCount: Integer;
  83. begin
  84. AppCount := 0;
  85. pProcesses := TStringList.Create;
  86. pProcesses.Text := GetRunningProcesses();
  87. for i := 0 to pProcesses.Count - 1 do
  88. begin
  89. if pProcesses.Strings[i] = 'LuaEdit.exe' then
  90. Inc(AppCount);
  91. end;
  92. Result := (AppCount > 1);
  93. pProcesses.Free;
  94. end;
  95. begin
  96. // Insure only one single instance of the application
  97. // If another instance is detected, we send the command line to it
  98. if CheckAppInstance() then
  99. begin
  100. copyDataStruct.dwData := Integer(cdtAnsiString);
  101. copyDataStruct.cbData := Length(CmdLine) + 1; // +1 NULL
  102. copyDataStruct.lpData := CmdLine;
  103. hChild := FindWindow('TfrmLuaEditMain',nil);
  104. if hChild <> 0 then
  105. begin
  106. hParent := GetWindowLong(hChild, GWL_HWNDPARENT);
  107. if hParent <> 0 then
  108. begin
  109. SendMessage(hParent, WM_SYSCOMMAND, SC_RESTORE, 0);
  110. SetForegroundWindow(hParent);
  111. end;
  112. SetForegroundWindow(hChild);
  113. SendMessage(hChild, WM_COPYDATA, Application.Handle, Integer(@copyDataStruct));
  114. end;
  115. Halt(1);
  116. end;
  117. Application.Initialize;
  118. Application.Title := 'LuaEdit';
  119. Application.HelpFile := 'C:\Prog\Delphi\LuaEditor\Bin\Help\LuaEdit.chm';
  120. Application.CreateForm(TfrmLuaEditMain, frmLuaEditMain);
  121. Application.CreateForm(TfrmAbout, frmAbout);
  122. Application.CreateForm(TfrmGotoLine, frmGotoLine);
  123. Application.CreateForm(TfrmReplace, frmReplace);
  124. Application.CreateForm(TfrmReplaceQuerry, frmReplaceQuerry);
  125. Application.CreateForm(TfrmSearch, frmSearch);
  126. Application.CreateForm(TfrmAddToPrj, frmAddToPrj);
  127. Application.CreateForm(TfrmErrorLookup, frmErrorLookup);
  128. Application.CreateForm(TfrmPrintSetup, frmPrintSetup);
  129. Application.CreateForm(TfrmPrjOptions, frmPrjOptions);
  130. Application.CreateForm(TfrmContributors, frmContributors);
  131. Application.CreateForm(TfrmAddBreakpoint, frmAddBreakpoint);
  132. Application.CreateForm(TfrmEditorSettings, frmEditorSettings);
  133. Application.CreateForm(TfrmAsciiTable, frmAsciiTable);
  134. Application.CreateForm(TfrmFindInFiles, frmFindInFiles);
  135. Application.CreateForm(TfrmSIFReport, frmSIFReport);
  136. Application.CreateForm(TfrmComponentList, frmComponentList);
  137. Application.CreateForm(TfrmGUID, frmGUID);
  138. Application.CreateForm(TfrmMacroManager, frmMacroManager);
  139. Application.CreateForm(TfrmConvertPath, frmConvertPath);
  140. frmLuaEditMain.CheckButtons;
  141. // show splash screen...
  142. frmSplash := TfrmSplash.Create(Application);
  143. frmSplash.Show;
  144. frmSplash.Update;
  145. for i := 0 to 3 do
  146. begin
  147. Application.ProcessMessages;
  148. Sleep(1000);
  149. end;
  150. frmSplash.Close;
  151. frmSplash.Free;
  152. LoadDockTreeFromFile(ExtractFilePath(Application.ExeName) + 'LuaEdit.dck');
  153. // Backward compatibility with the ini file (versions < 3.0)
  154. if FileExistsAbs(GetLuaEditInstallPath()+'\LuaEdit.ini') then
  155. begin
  156. frmLuaEditMain.LoadEditorSettingsFromReg;
  157. frmLuaEditMain.LoadEditorSettingsFromIni;
  158. end
  159. else
  160. frmLuaEditMain.LoadEditorSettingsFromReg;
  161. if ParamCount() > 0 then
  162. begin
  163. pFiles := TStringList.Create;
  164. for x := 1 to ParamCount() do
  165. begin
  166. FileName := ParamStr(x);
  167. if FileExistsAbs(FileName) then
  168. begin
  169. pFiles.Add(FileName);
  170. frmLuaEditMain.DoOpenFileExecute(pFiles);
  171. end;
  172. end;
  173. // Rebuild the project tree and initialize stuff
  174. frmProjectTree.BuildProjectTree;
  175. frmLuaEditMain.CheckButtons;
  176. pFiles.Free;
  177. end;
  178. Application.Run;
  179. end.