Changeset 61 for trunk/NewView/StartupUnit.pas
- Timestamp:
- Jan 14, 2007, 8:02:42 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NewView/StartupUnit.pas
r58 r61 13 13 OS2Def, 14 14 Classes, 15 ACLString,16 15 GlobalFilelistUnit, 17 16 SharedMemoryUnit, … … 24 23 function AccessSharedMemory: TSuballocatedSharedMemory; 25 24 26 // Returns true if the program should be started as normal.27 // False if it should immediately exit.28 function Startup: boolean;29 30 25 // Look for any items that are actually specifiying environment 31 26 // variables, and expand them to the contents of the variables … … 37 32 // the help and bookshelf paths. 38 33 Function FindHelpFile( FileName: string ): string; 34 Procedure PostNewViewTextMessage( Window: HWND; 35 MessageType: ULONG; 36 s: string ); 39 37 40 38 var 41 CmdLineParameters: TCmdLineParameters;42 39 SharedMemory: TSubAllocatedSharedMemory; 43 40 GlobalFilelist: TGlobalFilelist; … … 50 47 DebugUnit, 51 48 PMWin, 52 ACLUtility,53 49 ACLStringUtility, 54 50 ACLFileUtility, 55 AStringUtilityUnit,56 51 HelpManagerUnit; 57 52 … … 167 162 168 163 169 // If another instance already has the files open170 // activate it and return true.171 function FindExistingWindow: HWND;172 var173 FileItems: TStringList;174 Filenames: TStringList;175 FullFilePath: string;176 i: longint;177 178 FileWindow: HWND;179 begin180 Result := NULLHANDLE;181 182 if length(CmdLineParameters.getInterpretedFileNames) = 0 then183 // not loading files; nothing to check184 exit;185 186 FileItems := TStringList.Create;187 Filenames := TStringList.Create;188 189 StringToList(CmdLineParameters.getInterpretedFileNames, FileItems, '+' );190 TranslateIPFEnvironmentVars( FileItems, FileNames );191 192 for i := 0 to FileNames.Count - 1 do193 begin194 FullFilePath := FindHelpFile( Filenames[ i ] );195 if FullFilePath <> '' then196 begin197 FileWindow := GlobalFilelist.FindFile( FullFilePath );198 199 if FileWindow = NULLHANDLE then200 begin201 // not found - stop searching.202 Result := NULLHANDLE; // no match203 break;204 end;205 206 // found it207 208 // is it the same as any previous match?209 if Result <> NULLHANDLE then210 begin211 if FileWindow <> Result then212 begin213 // no, so we don't have a match.214 // NOTE: We just excluded something: if the same file is215 // open in multiple windows then we may not check all combinations216 Result := NULLHANDLE; // no match217 break;218 end;219 end220 else221 begin222 // no match yet - store this one223 Result := FileWindow;224 end;225 226 end;227 end;228 229 Filenames.Destroy;230 FileItems.Destroy;231 232 end;233 234 164 function AccessSharedMemory: TSuballocatedSharedMemory; 235 165 begin … … 253 183 end; 254 184 255 function Startup: boolean;256 var257 tmpCmdLine: String;258 ExistingWindow: HWND;259 begin260 // open shared memory261 SharedMemory := AccessSharedMemory;262 263 // get access to the system-global filelist264 GlobalFilelist := TGlobalFilelist.Create;265 266 // parse parameters into Parameters object267 tmpCmdLine := nativeOS2GetCmdLineParameter;268 269 CmdLineParameters := TCmdLineParameters.Create;270 CmdLineParameters.parseCmdLine(tmpCmdLine);271 272 ExistingWindow := FindExistingWindow;273 274 if ExistingWindow <> NULLHANDLE then275 begin276 // want to exit without running fully277 Result := false;278 279 // destroy global list - nobody else will280 GlobalFilelist.Destroy;281 282 WinSetFocus( HWND_DESKTOP, ExistingWindow );283 284 // topic search285 if not CmdLineParameters.getSearchFlag286 AND not CmdLineParameters.getGlobalSearchFlag287 AND (CmdLineParameters.getInterpretedSearchText <> '')288 then289 begin290 PostNewViewTextMessage( ExistingWindow,291 NHM_SEARCH,292 CmdLineParameters.getInterpretedSearchText);293 end;294 295 if CmdLineParameters.getGlobalSearchFlag then296 begin297 PostNewViewTextMessage( ExistingWindow,298 NHM_GLOBAL_SEARCH,299 CmdLineParameters.getInterpretedSearchText);300 end;301 302 if CmdLineParameters.getShowUsageFlag then303 begin304 WinPostMsg( ExistingWindow,305 NHM_SHOW_USAGE,306 0,307 0 );308 end;309 310 if CmdLineParameters.getHelpManagerFlag then311 begin312 // tell the new help manager instance to talk to the313 // other viewer314 WinPostMsg( CmdLineParameters.getHelpManagerWindow,315 NHM_VIEWER_READY,316 ExistingWindow,317 0 );318 end;319 320 end321 else322 begin323 // run as normal324 Result := true;325 end;326 end;327 185 328 186 Initialization
Note:
See TracChangeset
for help on using the changeset viewer.