home *** CD-ROM | disk | FTP | other *** search
- unit Main;
-
- { Program copyright (c) 1995 by Charles Calvert & Steve Teixeira }
- { Project Name: EXPLORER }
-
- interface
-
- uses
- WinTypes, WinProcs, Classes,
- Graphics, Forms, Controls,
- Messages, Menus, FileCtrl,
- Update, About, MakeCls,
- Welcome, Status, Buttons,
- StdCtrls, IniFiles, ExtCtrls;
-
- type
- TExplore = class(TForm)
- ListBox1: TListBox;
- ComboBox1: TComboBox;
- EUnitName: TEdit;
- MainMenu1: TMainMenu;
- File1: TMenuItem;
- Options1: TMenuItem;
- Eye: TBitBtn;
- ObjectModel1: TMenuItem;
- VCL1: TMenuItem;
- OWL1: TMenuItem;
- TurboVision1: TMenuItem;
- UpdateObjects1: TMenuItem;
- Exit1: TMenuItem;
- Help1: TMenuItem;
- About1: TMenuItem;
- Contents1: TMenuItem;
- Toolbar: TPanel;
- SpeedButton1: TSpeedButton;
- SpeedButton5: TSpeedButton;
- SpeedButton2: TSpeedButton;
- SpeedButton3: TSpeedButton;
- SpeedButton4: TSpeedButton;
- SpeedButton6: TSpeedButton;
- SpeedButton7: TSpeedButton;
- SpeedButton8: TSpeedButton;
- N1: TMenuItem;
- procedure FormDestroy(Sender: TObject);
- procedure EyeClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure Exit1Click(Sender: TObject);
- procedure Options1Click(Sender: TObject);
- procedure UpdateObjects1Click(Sender: TObject);
- procedure About1Click(Sender: TObject);
- procedure VCL1Click(Sender: TObject);
- procedure OWL1Click(Sender: TObject);
- procedure TurboVision1Click(Sender: TObject);
- procedure Contents1Click(Sender: TObject);
- procedure ComboBox1KeyPress(Sender: TObject; var Key: Char);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure FormActivate(Sender: TObject);
- private
- NewUser: Boolean;
- cbBuffer: PChar;
- vclPath: String;
- bpPath: String;
- oePath: String;
- ObjectList: String;
- TextEditor: String;
- ComboId: Word;
- SList: TStringList;
- procedure ResetUI;
- function GetAFile(S: String): String;
- function GetAParent(S: String): String;
- procedure WMCommand(var Msg: TWMCommand); message wm_Command;
- procedure HandleChange;
- procedure HandleFileChange;
- procedure SelectFirstItem;
- end;
-
- var
- Explore: TExplore;
-
- implementation
- uses
- DirStuff, Viewer, SysUtils, ExpIni, Dialogs, StrUtils;
-
- {$R *.DFM}
-
- function GetClass(S: String): String;
- begin
- Result := GetFirstWord(S);
- end;
-
- function TExplore.GetAFile(S: String): String;
- var
- i: Integer;
- Temp: String;
- Parent: String;
- Total: Integer;
- begin
- Parent := '';
- Total := SList.Count - 1;
- for i := 0 to Total do begin
- Temp := SList.Strings[i];
- if GetFirstWord(Temp) = S then begin
- Move(Temp[53], Parent[1], 26);
- Parent[0] := Chr(Length(Temp) - 52);
- Parent := StripSpaces(Parent);
- break;
- end;
- end;
- GetAFile := Parent;
- end;
-
- function TExplore.GetAParent(S: String): String;
- var
- i: Integer;
- Temp: String;
- Total: Integer;
- begin
- Result := '';
- Total := SList.Count - 1;
- for i := 0 to Total do begin
- Temp := SList.Strings[i];
- if CompareStr(GetFirstWord(Temp), S) = 0 then begin
- Move(Temp[27], Result[1], 26);
- Result[0] := #26;
- Result := StripSpaces(Result);
- break;
- end;
- end;
- end;
-
- procedure TExplore.HandleChange;
- var
- S: String;
- i: Integer;
- begin
- ListBox1.Clear;
- S := ComboBox1.Items.Strings[ComboBox1.ItemIndex];
- ListBox1.Items.Add(S);
- EUnitName.Text := GetAFile(S);
- repeat
- S := GetAParent(S);
- ListBox1.Items.Add(S);
- until (S = 'TObject') or (S = '');
- end;
-
- procedure TExplore.HandleFileChange;
- var
- S: String;
- begin
- S := ListBox1.Items.Strings[ListBox1.ItemIndex];
- if S = 'TObject' then
- EUnitName.Text := 'SYSTEM.PAS'
- else
- EUnitName.Text := GetAFile(S);
- end;
-
- procedure TExplore.WMCommand(var Msg: TWMCommand);
- begin
- if Msg.ItemId = ComboId then
- if Msg.NotifyCode = lbn_SelChange then
- HandleChange;
-
- if Msg.Ctl = ListBox1.Handle then
- if Msg.NotifyCode = lbn_SelChange then
- HandleFileChange;
- inherited;
- end;
-
- procedure TExplore.FormDestroy(Sender: TObject);
- begin
- IniFile.WriteString('SETTINGS', 'CurrObject', ObjectList);
- IniFile.WriteInteger('SETTINGS', 'XPos', Left);
- IniFile.WriteInteger('SETTINGS', 'YPos', Top);
- FreeMem(cbBuffer, 256);
- IniFile.Free;
- SList.Free;
- end;
-
- procedure TExplore.EyeClick(Sender: TObject);
- var
- Path: String;
- S: String;
- A: array[0..255] of char;
- WERetVal: word;
- begin
- if Listbox1.ItemIndex < 0 then
- Listbox1.ItemIndex := 0;
- ListBox1.SetFocus;
- FileViewer.Edit1.Text := ListBox1.Items.Strings[ListBox1.ItemIndex];
- if FileViewer.Edit1.Text = '' then
- FileViewer.Edit1.Text := ListBox1.Items.Strings[0];
- if ObjectList = 'delobj.lst' then begin
- S := UpperCase(EUnitName.Text);
- if (S = 'EXCEPTS.PAS') or (S = 'SYSTEM.PAS') or (S = 'SYSUTILS.PAS') then
- Path := vclPath + 'rtl\sys\'
- else if (S = 'CALENDAR.PAS') or (S = 'COLORGRD.PAS') or (S = 'DIROUTLN.PAS')
- or (S = 'GAUGES.PAS') or (S = 'SPIN.PAS') then
- Path := vclPath + 'samples\'
- else
- Path := vclPath + 'vcl\';
- end
- else if ObjectList = 'owlobj.lst' then
- Path := bpPath+'owl\'
- else if ObjectList = 'tvobj.lst' then begin
- if (S = 'OBJECTS.PAS') or (S = 'VALIDATE.PAS') then
- Path := bpPath+'common\'
- else
- Path := bpPath+'tv\';
- end;
- S := Path + S;
- if not FileExists(S) then
- MessageDlg('Can''t find file, Run Options', mtError, [mbOk], 0)
- else try
- FileViewer.ListBox1.Items.LoadFromFile(S);
- FileViewer.FileName := S;
- FileViewer.Show;
- except
- on E:EOutOfResources do begin
- if MessageDlg('File to large for Viewer. Load into text editor?',
- mtError, [mbYes, mbNo], 0) = mrYes then begin
- StrPCopy(A, TextEditor + ' ' + S);
- WERetVal := WinExec(A, sw_ShowNormal);
- if WERetVal < 32 then
- MessageDlg('Couldn''t spawn editor. Error code: ' +
- IntToStr(WERetVal), mtError, [mbOk], 0);
- end;
- end;
- end;
- end;
-
- procedure TExplore.FormCreate(Sender: TObject);
-
- procedure GetoePath;
- var
- S : String;
- i : Integer;
- begin
- S := ParamStr(0);
- i := integer(S[0]);
- while S[i] <> '\' do
- begin
- dec(S[0]);
- dec(i);
- end;
- oePath := S;
- end;
-
- const
- Size = 128;
- var
- P: array[0..Size] of Char;
- i: Integer;
- S : String;
- H: Hwnd;
- begin
- GetMem(cbBuffer, 256);
- Left := IniFile.ReadInteger('SETTINGS', 'XPos', Left);
- Top := IniFile.ReadInteger('SETTINGS', 'YPos', Top);
- Toolbar.ShowHint := IniFile.ReadBool('SETTINGS', 'BubbleHelp', True);
- vclPath := AddBackSlash(IniFile.ReadString('PATHS', 'vclpath',
- 'c:\delphi\source\'));
- bpPath := AddBackSlash(IniFile.ReadString('PATHS', 'bppath', 'c:\bp\rtl\'));
- ObjectList := IniFile.ReadString('SETTINGS', 'CurrObject', 'delobj.lst');
- TextEditor := IniFile.ReadString('SETTINGS', 'TextEditor', 'notepad.exe');
- if ObjectList = 'owlobj.lst' then
- begin
- VCL1.Checked := False;
- OWL1.Checked := True;
- TurboVision1.Checked := False;
- Caption := 'Object Explorer - OWL';
- end
- else if ObjectList = 'tvobj.lst' then
- begin
- VCL1.Checked := False;
- OWL1.Checked := False;
- TurboVision1.Checked := True;
- Caption := 'Object Explorer - TV';
- end;
- GetoePath;
- if not (HasIni and FileExists(oePath+ObjectList)) then begin
- WelcomeDlg := TWelcomeDlg.Create(Self);
- WelcomeDlg.ShowModal;
- WelcomeDlg.Free;
- NewUser := True;
- end;
- SList := TStringList.Create;
- SList.Sorted := True;
- if not NewUser then begin
- SList.LoadFromFile(oePath+ObjectList);
- for i := 0 to SList.Count - 1 do
- ComboBox1.Items.Add(GetClass(SList.Strings[i]));
- if ParamCount > 0 then begin
- i := SendMessage(ComboBox1.Handle, cb_SelectString, 0, Longint(StrPCopy(cbBuffer, ParamStr(1))));
- H := GetDlgItem(ComboBox1.Handle, 1000);
- SendMessage(H, lb_SetTopIndex, i, 0);
- end
- else
- SelectFirstItem;
- end;
- ComboId := GetDlgCtrlId(ComboBox1.Handle);
- end;
-
- procedure TExplore.Exit1Click(Sender: TObject);
- begin
- Close;
- end;
-
- procedure TExplore.Options1Click(Sender: TObject);
- var
- p: array[0..100] of Char;
- begin
- with OptionsWin do begin
- EDelphiSource.Text := vclPath;
- EBPSource.Text := bpPath;
- if ShowModal = mrOk then
- begin
- vclPath := EDelphiSource.Text;
- bpPath := EBPSource.Text;
- TextEditor := ETextEditor.Text;
- IniFile.WriteString('PATHS', 'vclpath', AddBackSlash(vclPath));
- IniFile.WriteString('PATHS', 'bppath', AddBackSlash(bpPath));
- IniFile.WriteString('SETTINGS', 'CurrObject', ObjectList);
- IniFile.WriteString('SETTINGS', 'TextEditor', TextEditor);
- IniFile.WriteBool('SETTINGS', 'BubbleHelp', Checkbox1.Checked);
- Toolbar.ShowHint := Checkbox1.Checked;
- end;
- end;
- end;
-
-
- procedure TExplore.UpdateObjects1Click(Sender: TObject);
- var
- DirList : TStringList;
- begin
- UpdateDlg.CheckBox1.Checked := False;
- UpdateDlg.CheckBox2.Checked := False;
- UpdateDlg.CheckBox3.Checked := False;
- UpdateDlg.ShowModal;
- if UpdateDlg.ModalResult = mrOk then begin
- UpStatus := TUpStatus.Create(Self);
- DirList := TStringList.Create;
- If UpdateDlg.CheckBox1.Checked = True then
- begin
- DirList.Clear;
- DirList.Add(vclPath + 'vcl');
- DirList.Add(vclPath + 'rtl\sys\');
- DirList.Add(vclPath + 'samples\');
- UpStatus.Label1.Caption := 'Class Library: VCL';
- MakeList(DirList, (oePath + 'delobj.lst'));
- end;
- If UpdateDlg.CheckBox2.Checked = True then
- begin
- DirList.Clear;
- DirList.Add(bpPath+'owl\');
- DirList.Add(bpPath+'win\');
- DirList.Add(bpPath+'win31\');
- DirList.Add(bpPath+'common\');
- UpStatus.Label1.Caption := 'Object Library: OWL';
- MakeList(DirList, (oePath + 'owlobj.lst'));
- end;
- If UpdateDlg.CheckBox3.Checked = True then
- begin
- DirList.Clear;
- DirList.Add(bpPath+'tv\');
- DirList.Add(bpPath+'common\');
- UpStatus.Label1.Caption := 'Object Library: TV';
- MakeList(DirList, (oePath + 'tvobj.lst'));
- end;
- UpStatus.Free;
- DirList.Free;
- ResetUI;
- end;
- end;
-
- procedure TExplore.About1Click(Sender: TObject);
- begin
- AboutDlg.ShowModal;
- end;
-
- procedure TExplore.SelectFirstItem;
- begin
- if ComboBox1.Items.Count > 0 then begin
- SendMessage(ComboBox1.Handle, cb_SetCurSel, 1, 0);
- SendMessage(ComboBox1.Handle, wm_KeyDown, vk_Up, 0);
- end;
- end;
-
- procedure TExplore.ResetUI;
- var
- i: integer;
- begin
- EUnitName.Text := '';
- ComboBox1.Text := '';
- ComboBox1.Items.Clear;
- SList.Clear;
- SList.LoadFromFile(oePath+ObjectList);
- for i := 0 to SList.Count - 1 do
- ComboBox1.Items.Add(GetClass(SList.Strings[i]));
- SelectFirstItem;
- end;
-
- procedure TExplore.VCL1Click(Sender: TObject);
- begin
- VCL1.Checked := True;
- OWL1.Checked := False;
- TurboVision1.Checked := False;
- Caption := 'Delphi Explorer - VCL';
- ObjectList := 'delobj.lst';
- ResetUI;
- end;
-
- procedure TExplore.OWL1Click(Sender: TObject);
- begin
- VCL1.Checked := False;
- OWL1.Checked := True;
- TurboVision1.Checked := False;
- Caption := 'Delphi Explorer - OWL';
- ObjectList := 'owlobj.lst';
- ResetUI;
- end;
-
- procedure TExplore.TurboVision1Click(Sender: TObject);
- begin
- VCL1.Checked := False;
- OWL1.Checked := False;
- TurboVision1.Checked := True;
- Caption := 'Delphi Explorer - TV';
- ObjectList := 'tvobj.lst';
- ResetUI;
- end;
-
- procedure TExplore.Contents1Click(Sender: TObject);
- begin
- Application.HelpContext(0);
- end;
-
- procedure TExplore.ComboBox1KeyPress(Sender: TObject; var Key: Char);
- var
- I: integer;
- H: hWnd;
- begin
- if Key = #13 then begin
- H := GetDlgItem(ComboBox1.Handle, 1000);
- I := SendMessage(H, lb_GetTopIndex, 0,
- Longint(StrPCopy(cbBuffer, ComboBox1.Text)));
- ComboBox1.ItemIndex := I;
- HandleChange;
- end;
- end;
-
- procedure TExplore.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- Application.HelpCommand(Help_Quit, 0);
- end;
-
- procedure TExplore.FormActivate(Sender: TObject);
- var
- H: hWnd;
- I: integer;
- begin
- if NewUser then begin
- Options1Click(nil);
- UpdateObjects1Click(nil);
- SList.LoadFromFile(oePath+ObjectList);
- for i := 0 to SList.Count - 1 do
- ComboBox1.Items.Add(GetClass(SList.Strings[i]));
- if ParamCount > 0 then begin
- i := SendMessage(ComboBox1.Handle, cb_SelectString, 0, Longint(StrPCopy(cbBuffer, ParamStr(1))));
- H := GetDlgItem(ComboBox1.Handle, 1000);
- SendMessage(H, lb_SetTopIndex, i, 0);
- end
- else
- SelectFirstItem;
- NewUser := False;
- end;
- end;
-
- end.
-