⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 objectinspec.~pas

📁 delphi 写的delphi的程序 Handel is a free, standalone development tool created with Delphi 3 that enable
💻 ~PAS
📖 第 1 页 / 共 4 页
字号:
     VK_UP:
        if PropertyBox.ItemIndex >= 1 then
        begin
           if edProperty.Modified then
           begin //Edit狼 郴侩捞 荐沥登菌栏搁
              PropSetValue(edProperty.Text);
              with PropertyBox do
                 Items[ItemIndex]:= Format('%-20s',[GetPropertyName]) + edProperty.Text;
           end;
        end;
     VK_F1:
        ShowHelp;
   end;
   if (Key in [vk_up, vk_down, vk_prior, vk_next]) then
   begin
      PropertyBox.SetFocus;
      PostMessage(PropertyBox.Handle, WM_KeyDown, Key, 0);
      Key := 0;
   end;
end;

procedure TObjectInspector.edPropertyKeyPress(Sender: TObject;
  var Key: Char);
begin
   if Key = #13 then
   begin
      PropertyBox.SetFocus;
      PropSetValue(edProperty.Text);
      with PropertyBox do
         Items[ItemIndex]:= Format('%-20s',[GetPropertyName]) + edProperty.Text;
   end;
end;

procedure TObjectInspector.cbValueChange(Sender: TObject);
begin
   PropSetValue(cbValue.Text);
   with PropertyBox do
       Items[ItemIndex]:= Format('%-20s',[GetPropertyName]) + cbValue.Text;
end;

procedure TObjectInspector.cbValueKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
   if Key = vk_Return then
   begin
      PropertyBox.SetFocus;
      Key := 0;
      Exit;
   end;
   if Key =  VK_F1 then ShowHelp;
   if (Key in [vk_up, vk_down, vk_prior, vk_next]) then
   begin
      PropertyBox.Setfocus;
      PostMessage(PropertyBox.Handle, WM_KeyDown, Key, 0);
      Key := 0;
   end;
end;

procedure TObjectInspector.cbValueDrawItem(Control: TWinControl;
  Index: Integer; Rect: TRect; State: TOwnerDrawState);
begin
  with (Control as TComboBox).Canvas do
  begin
    FillRect(Rect);
   // Font.Color := clNavy;
    TextOut(Rect.Left, Rect.Top, cbValue.Items[Index]);
  end;
end;

procedure TObjectInspector.FormActivate(Sender: TObject);
begin
  InitializeInspector;
  if ComponentList.ItemIndex = -1 then  ComponentList.ItemIndex:=0;
end;

// 货肺款 汽阑 累己窍芭唱 汽 荤捞甫 傈券且 锭 Object Inspector狼 沥焊甫
// 汽俊 嘎霸 促矫 佬绰促.
procedure TObjectInspector.InitializeInspector;
var
  I:Integer;
begin
   if ProxyDesigner = nil then Exit;
   ComponentList.Clear;
   ComponentList.Items.Add(ProxyDesigner.Form.Name+':' +ProxyDesigner.Form.ClassName);
   with ProxyDesigner.Form do
   begin
    for I:=0 to  ComponentCount-1 do
        if not ProxyDesigner.IsDesignedComponent(Components[I]) then
           ComponentList.Items.Add(Components[I].Name+':'+Components[I].ClassName)
    end;
    ComponentList.ItemIndex:= GetItemIndex(SelectComponent);
   // ComponentList.ItemIndex:= -1;
end;

// 哪欺惩飘 格废俊辑 哪欺惩飘甫 急琶窍绰 版快, 秦寸 哪欺惩飘甫 急琶窍绊 加己阑 焊咯霖促.
procedure TObjectInspector.ComponentListClick(Sender: TObject);
var
  Component:TComponent;
  Wrapper:TComponent;
begin
   Component := GetComponent(Wrapper);
   DisplayProperty(Wrapper,Component);
end;

procedure TObjectInspector.PropertyBoxDblClick(Sender: TObject);
var
  Po:TPoint;
  PropInfo:PPropInfo;
  PropName:string;
  Editor:TPropertyEditor;
begin
   GetCursorPos(Po);
   Po:= PropertyBox.ScreenToClient(Po);
   if Po.x < HalfWay then
   begin
      if PropertyBox.Items[PropertyBox.ItemIndex][1] = '+' then
      begin
         PropName:= Trim(Copy(PropertyBox.Items[PropertyBox.ItemIndex],2,20));
         PropertyBox.Items[PropertyBox.ItemIndex]:= '-' + PropName;
         //PropInfo:= GetPropInfo(SelectComponent.ClassInfo, PropName);
         //InsertPropInfo(PropInfo, SelectComponent);
         Editor:= TPropertyEditor(PropertyList.Objects[PropertyBox.ItemIndex]);
         if Editor <> nil then
            Editor.GetProperties(GetSubPropEditor);
      end
      else if PropertyBox.Items[PropertyBox.ItemIndex][1] = '-' then
      begin
         PropName:= Trim(Copy(PropertyBox.Items[PropertyBox.ItemIndex],2,20));
         PropertyBox.Items[PropertyBox.ItemIndex]:= '+' + PropName;
         PropInfo:= GetPropInfo(SelectComponent.ClassInfo, PropName);
         DeletePropInfo(PropInfo, SelectComponent);
      end;
   end;
end;

//cbValue狼 ItemIndex甫 Text阑 啊瘤绰 牢郸胶肺 汲沥茄促.
// cbValue狼 Style甫 csDropDownList肺 汲沥沁扁 锭巩俊
// cbValue.Text:= Text鄂 巩厘捞 家侩捞 绝扁 锭巩捞促.
procedure TObjectInspector.SetcbValueIndex(Text:string);
var
  Index:Integer;
begin
   Index:= cbValue.Items.IndexOf(Text);
   if Index<>-1 then cbValue.ItemIndex:= Index
   else cbValue.Text:= GetPropertyValueName;
end;

procedure TObjectInspector.ShowHelp;
var
  KeyWord:string;
begin
   KeyWord:= Trim(Copy(PropertyBox.Items[PropertyBox.ItemIndex],1,20));
   Application.HelpCommand(HELP_KEY,longint(KeyWord));
end;

function TObjectInspector.GetClassList(ClassName:string;CanParent:Boolean):string;
// ClassName牢 葛电 哪欺惩飘狼 格废阑 倒妨霖促.
var
  I:Integer;
  List:TStringList;
  CName, CType, S:string;
  Class1:TClass;
  CurComponent:TComponent;
begin
   Result:= '';
   List:= TStringList.Create;
   for I:= 0 to ComponentList.Items.Count - 1 do
   begin
      CName:= ComponentList.Items[I];
      CType:= ExtractComponentType(CName);
      if CanParent then
      begin
         Class1:= FindClass(ClassName);
         S:= ExtractComponentName(CName);
         CurComponent:= ProxyDesigner.Form.FindComponent(S);
         if (CurComponent is Class1 ) then List.Add(S);
      end
      else if CompareText(CType, ClassName) = 0 then
         List.Add(ExtractComponentName(CName));
   end;
   Result:= List.Text;
   List.Free;
end;

procedure TObjectInspector.GetPrpoertyItemList(ClassName:string;CanParent:Boolean);
// MainMenu, DataSource 殿苞 鞍篮 加己俊 措秦 啊龙 荐 乐绰 亲格阑 炼荤茄促.
// CanParent啊 True牢 版快 何葛 努贰胶鳖瘤 厚背茄促.
var
  ClassType:TClass;
begin
   ClassType:= FindClass(ClassName);
   cbValue.Items.Text:= GetClassList(ClassName, CanParent);
   SetEditBounds(cbValue);
end;

procedure TObjectInspector.GetDatabaseNameList;
var
   List:TStringList;
begin
  {$IFDEF DBVERSION}
   List:= TStringList.Create;
   Session.GetDatabaseNames(List);
   cbValue.Items.Assign(List);
   SetEditBounds(cbValue);
   List.Free;
   {$ENDIF}
end;

procedure TObjectInspector.GetTableNameList;
var
   List:TStringList;
   DBName:string;
begin
   List:= TStringList.Create;
   DBName:= GetPropertyBoxValue('DatabaseName');
   {$IFDEF DBVERSION}
   Session.GetTableNames(DBName,'', False, False, List);
   {$ENDIF}
   cbValue.Items.Assign(List);
   SetEditBounds(cbValue);
   List.Free;
end;


procedure TObjectInspector.HideItemClick(Sender: TObject);
begin
   Hide;
end;

procedure TObjectInspector.StayOnTopItemClick(Sender: TObject);
begin
   StayOnTopItem.Checked:= not StayOnTopItem.Checked;
   if StayOnTopItem.Checked then FormStyle:= fsStayOnTop
   else FormStyle:= fsNormal;
end;

procedure TObjectInspector.InformationItemClick(Sender: TObject);
begin
   with TRTTIForm.Create(self) do
   begin
      if SelectComponent <> nil then
      begin
         if PageControl1.ActivePage = TabProperty then
         begin
            Caption:= 'RunTime Type Information(RTTI) about '+ PropertyName + ' of '+ SelectComponent.Name;
            WriteTypeInfo(SelectComponent.ClassInfo, PropertyName, PropertyEditor);
         end
         else if PageControl1.ActivePage = TabEvent then
         begin
            Caption:= 'RunTime Type Information(RTTI) about '+ GetEventName + ' of '+ SelectComponent.Name;
            WriteTypeInfo(SelectComponent.ClassInfo, GetEventName, PropertyEditor);
         end;
      end;
      ShowModal;
      Free;
   end;
end;

procedure TObjectInspector.EditEventHandler(Index: Integer);
// 捞亥飘狼 Index锅掳甫 祈笼茄促.
begin
    PageControl1.ActivePage:= ObjectInspector.TabEvent;
    EventBox.ItemIndex:= Index;
    EventBoxClick(self);
    cbEventDblClick(self);
end;

procedure TObjectInspector.cbEventDblClick(Sender: TObject);
var
   EventName, Event: string;
   EventHandler:string;
   Editor: TPropertyEditor;
   Method: TMethod;

   procedure SetEventValue;
   var
     PropInfo: PPropInfo;
   begin
      PropInfo:= GetPropInfo(SelectComponent.ClassInfo, Event);
      if PropInfo <> nil then
         SetMethodProp(SelectComponent, PropInfo, Method);
   end;
   
begin
    Editor      := EventList.Objects[EventBox.ItemIndex] as TPropertyEditor;
    Event       := Trim(Copy(EventBox.Items[EventBox.ItemIndex], 1, 20));
    EventName   := ExtractComponentName(ComponentList.Text);
    EventName   := EventName + Copy(Event ,3 ,20);
    EventHandler:= EventName;
    // get event's parameters
    EventName   := EventName+'('+WriteMethodData(GetTypeData(PropertyEditor.GetPropType))+');';
    // 捞亥飘 勤甸矾甫 累己窍瘤 臼疽栏搁 捞亥飘 勤甸矾甫 累己窍绊, 内靛 祈笼扁甫 劝己拳茄促.
    if not EditorForm.SetFocusEventHandler(EventName) then
       EditorForm.WriteEventCode(EventName);
    with EventBox do
       Items[ItemIndex]:=
          Format('%20s%s',[Copy(Items[ItemIndex],1,20),EventHandler]);
    Method:= ProxyDesigner.CreateMethod(EventHandler, GetTypeData(PropertyEditor.GetPropType));
    SetEventValue;
    PropSetValue(EventHandler);
end;

procedure TObjectInspector.cbEventKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
   if Key = vk_Return then
   begin
      EventBox.SetFocus;
      Key := 0;
      Exit;
   end;
   if Key =  VK_F1 then ShowHelp;
   if (Key in [vk_up, vk_down, vk_prior, vk_next]) then
   begin
      EventBox.Setfocus;
      PostMessage(EventBox.Handle, WM_KeyDown, Key, 0);
      Key := 0;
   end;
end;

function TObjectInspector.GetItemIndex(Component: TComponent): Integer;
var
   Name: string;
begin
   Result:= -1;
   if Component = nil then Exit;
   Name:= Component.ClassName;
   Result:= ComponentList.Items.IndexOf(Component.Name+':'+Name);
end;

procedure TObjectInspector.InsertIntoList(Item: string; LineNumber: Integer; Child: Boolean);
var
 CurrentItem : Integer;
 Added       : Boolean;
 Node        : TTreeNode;
begin
   Added := False;
   for CurrentItem := 0 to TreeView.Items.Count - 1 do
   begin
    if TreeView.Items[CurrentItem].Text = Item then // Procedure/function is in list
    begin
     TreeView.Items[CurrentItem].Data := Pointer(Linenumber); // Change Linenumber
     Added := True;
     break;
    end;
   end;
   if not added then // new procedure/function
   begin
    if child then // it is a procedure/function, so add node as child of topnode
    begin
     Node := TreeView.Items.AddChildObject(TreeView.TopItem, Item, Pointer(LineNumber));
     Node.ImageIndex := 1;
     Node.SelectedIndex := 2;
    end
    else // it is 'implementation', add it as first node
    begin
     Node := TreeView.Items.AddObject(TreeView.TopItem, Item, Pointer(LineNumber));
     Node.ImageIndex := 0;
     Node.SelectedIndex := 0;
    end;
    TreeView.TopItem.Expand(False);
   // TreeView.CustomSort(@CustomSortProc, 0); // sort the list
   end;
end;

procedure TObjectInspector.TreeViewDblClick(Sender: TObject);
var
  Node: TTreeNode;
begin
  if TreeView.Selected = nil then Exit;
  Node := TreeView.Selected;
  if Node <> nil then
  begin
    ActivePasEditor.TopLine := Integer(Node.Data) + 1; // Move procedure to top of editor
    ActivePasEditor.CaretY := Integer(Node.Data) + 1; // Move caretposition to top of editor
    ActivePasEditor.SetFocus;
  end;
end;

procedure TObjectInspector.PageControl1Change(Sender: TObject);
begin
   if PageControl1.ActivePage = TabCodeExplorer then
   begin
      FMainForm.ViewCodeExplorerItem.Checked:= True;
      ActivePasEditor.RefreshAllTokens;
   end;
end;

procedure TObjectInspector.AlphaSort1Click(Sender: TObject);
begin
   if TreeView.SortType = stText then TreeView.SortType:= stNone;
   TreeView.SortType:= stText;
end;

procedure TObjectInspector.LineSort1Click(Sender: TObject);
begin
   TreeView.SortType:= stNone;
   Treeview.Items.BeginUpdate;
   TreeView.CustomSort(@CustomSortProc, 0);
   TreeView.Items.EndUpdate;
end;

procedure TObjectInspector.ReFresh1Click(Sender: TObject);
begin
   TreeView.Items.BeginUpdate;
   TreeView.Items.Clear;
   ActivePasEditor.RefreshAllTokens;
   TreeView.Items.EndUpdate;
end;

procedure TObjectInspector.TreeViewChange(Sender: TObject;
  Node: TTreeNode);
var
  Node1: TTreeNode;
begin
  if TreeView.Selected = nil then Exit;
  Node1 := TreeView.Selected;
  if Node1 <> nil then
  begin
    StatusBar1.SimpleText := Format('%s %s %d', [Node1.Text, ':', Integer(Node1.Data)]);
  end;
end;

procedure TObjectInspector.cbEventClick(Sender: TObject);
var
  EventHandler: string;
begin
   EventHandler:= cbEvent.Text;
   with EventBox do
      Items[ItemIndex]:=
         Format('%20s%s',[Copy(Items[ItemIndex],1,20), EventHandler]);
   PropSetValue(EventHandler);
end;

end.


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -