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

📄 utype.pas

📁 delphi 写的delphi的程序 Handel is a free, standalone development tool created with Delphi 3 that enable
💻 PAS
📖 第 1 页 / 共 4 页
字号:
   NewMenuItem.OnClick:= TProxyForm(Form).OnMenuClick;
   if ImgIndex <> -1 then NewMenuItem.ImageIndex:= ImgIndex;
   Menu.Items.Add(NewMenuItem);
end;
begin
   Component:= Form.FindComponent('ProxyPopupMenu1');
   if Component <> nil then Component.Free;
   Menu       := TPopupMenu.Create(Form);
   Menu.Name  := 'ProxyPopupMenu1';
   Menu.Images:= FMainForm.ImageList;
   AddMenuItem(Menu, 'Cu&t'           ,'pmCut'       , True , 0);
   AddMenuItem(Menu, '&Copy'          ,'pmCopy'      , True , 1);
   if ClipBoard.HasFormat(CF_COMPONENT) then
      AddMenuItem(Menu, '&Paste'      ,'pmPaste'     , True , 2)
   else AddMenuItem(Menu, '&Paste'    ,'pmPaste'     , False, 2);
   AddMenuItem(Menu, '&Delete'        ,'pmDelete'    , True , 5);
   AddMenuItem(Menu, '-'              ,'pmSepa1'     , True , -1);
   AddMenuItem(Menu, 'Bring to &Front','pmFront'     , True , 58);
   AddMenuItem(Menu, 'Send to &Back'  ,'pmBack'      , True , 57);
   AddMenuItem(Menu, '-'              ,'pmSepa2'     , True , -1);
   AddMenuItem(Menu, '&Align...'      ,'pmAlign'     , True , 54);
   AddMenuItem(Menu, '&Size...'       ,'pmSize'      , True , 60);
   AddMenuItem(Menu, 'Scal&e...'      ,'pmScale'     , True , 56);
   AddMenuItem(Menu, '&View as Text'  ,'pmViewAsText', True , -1);
   GetCursorPos(Po);
   Menu.Popup(Po.X, Po.Y);
   Result:= Menu;
  // Form.Dispatch(Message);
end;

// 橇废矫 汽俊辑 惯积窍绰 MouseDown 皋技瘤甫 贸府茄促.
procedure TProxyDesigner.ProcessRMouseDown(Sender:TControl;Message:TMessage);
begin
   CreatePopupMenu;
end;

// 橇废矫 汽俊辑 惯积窍绰 MouseDown 皋技瘤甫 贸府茄促.
procedure TProxyDesigner.ProcessMouseDown(Sender:TControl;Message:TMessage);
var
  Control:TComponent;
begin
   // 目辑 困摹俊 乐绰 哪欺惩飘甫 急琶窍绊, 弊 加己阑 Inspector俊 焊咯霖促.
   Control:= Sender;
   if (Control <> nil) and (TProxyForm(Form).SelectControl <> Sender) then
   begin
      if Control.ClassType = TWrapperControl then
         ObjectInspector.DisplayProperty(Control,(Control as TWrapperControl).Component)
      else if Control.ClassType = TMenuItemButton then Exit
      else if  Control.ClassType<>TGrabHandle then
         if fMultiSelected then SelectComponent(Control)
         else ObjectInspector.DisplayProperty(nil,Control);
   end;
   TProxyForm(Form).SelectControl:= Sender;
   Form.Dispatch(Message);   // 汽俊 皋技瘤甫 傈崔茄促.
end;

// 橇废矫 汽俊辑 惯积窍绰 MouseMove 皋技瘤甫 贸府茄促.
procedure TProxyDesigner.ProcessMouseMove(Sender:TControl;Message:TMessage);
begin
   if fMultiSelected then Exit;
   Form.Dispatch(Message);
end;

// 橇废矫 汽俊辑 惯积窍绰 MouseUp 皋技瘤甫 贸府茄促.
procedure TProxyDesigner.ProcessMouseUp(Sender:TControl;Message:TMessage);
begin
   Form.Dispatch(Message);
end;

// 橇废矫 汽俊辑 惯积窍绰 DblClick 皋技瘤甫 贸府茄促.
// DblClick俊 措茄 扁夯利牢 贸府绰 哪欺惩飘 祈笼扁甫 龋免窍绰 巴捞促.
procedure TProxyDesigner.ProcessDblClick(Sender:TControl;Message:TMessage);
var
  CompEditor: TDefaultEditor;
begin
  { with ObjectInspector do begin
      SetFocus;
      PageControl1.ActivePage:= ObjectInspector.TabEvent;
      EventBox.ItemIndex:=0;
      EventBoxClick(self);
      edEventDblClick(self);
   end;}
   CompEditor:= TDefaultEditor(GetComponentEditor(Sender, ProxyDesigner));
   if CompEditor <> nil then
     if CompEditor is TYB_DefaultEditor then
        TYB_DefaultEditor(CompEditor).Edit
     else CompEditor.Edit;
end;

// 橇废矫 汽俊辑 惯积窍绰 KeyDown 皋技瘤甫 贸府茄促.
procedure TProxyDesigner.ProcessKeyDown(Message:TMessage);
var
  KeyWord:string;
begin
   case TWMKey(Message).CharCode of
       VK_DELETE:
          DeleteSelectList;
       VK_F1:
       begin
          KeyWord:= TProxyForm(Form).SelectControl.ClassName;
          Application.HelpCommand(HELP_KEY, longint(KeyWord));
       end;
       VK_LEFT,VK_UP,VK_RIGHT,VK_DOWN:
       begin
          if fControlPressed then MoveControl(TWMKey(Message).CharCode);
       end;
       VK_F11:
          ObjectInspector.SetFocus;
       VK_F12:
          FMainForm.ToggleFormAndUnit;
       VK_SHIFT :
          fMultiSelected:= True;
       VK_CONTROL :
          fControlPressed:= True;
   end;
  // Form.Dispatch(Message);
end;

// 橇废矫 汽俊辑 惯积窍绰 KeyUp 皋技瘤甫 贸府茄促.
procedure TProxyDesigner.ProcessKeyUp(Message:TMessage);
begin
   case TWMKey(Message).CharCode of
       VK_SHIFT :
          fMultiSelected:= False;
       VK_CONTROL :
       begin
          fControlPressed:= False;
          UpdateGrabHandle;
       end;
   end;
  // Form.Dispatch(Message);
end;

procedure TProxyDesigner.UpdateGrabHandle;
// Update grabs position
var
  I:Integer;
begin
   for I:=0 to fGrabList.Count - 1 do
     if Assigned(fGrabList[I]) then TGrabHandles(fGrabList[I]).Update;
end;

// Copy selected components to clipboard
procedure TProxyDesigner.CopyComponent;
var
  S: TMemoryStream;
  W: TWriter;
  I: Integer;
begin
  S := TMemoryStream.Create;
  try
    W := TWriter.Create(S, 1024);
    try
      W.Root := Form;
      for I := 0 to fSelectList.Count - 1 do
      begin
        W.WriteSignature;
        W.WriteComponent(TComponent(fSelectList[I]));
      end;
      W.WriteListEnd;
    finally
      W.Free;
    end;
    SetBuffer(CF_COMPONENT, S.Memory^, S.Size);
  finally
    S.Free;
  end;
end;

procedure TProxyDesigner.UndoComponent;
begin
end;

// Cut selected compoenents
procedure TProxyDesigner.CutComponent;
begin
   CopyComponent;
   DeleteSelectList;
   FMainForm.UpdateControl(psChange);
   FUndoList.AddChange(utCut, '');
end;

// Paste components
procedure TProxyDesigner.PasteComponent;
var
  S: TMemoryStream;
  R: TReader;
  Data: THandle;
  DataPtr: Pointer;
begin
  ClipBoard.Open;
  Data := GetClipboardData(CF_COMPONENT);
  if Data = 0 then Exit;
  DataPtr := GlobalLock(Data);
  if DataPtr = nil then Exit;
  S:= TMemoryStream.Create;
  ClearGrabHandles;
  fMultiSelected:= True;
  try
    S.WriteBuffer(DataPtr^, GlobalSize(Data));
    S.Position := 0;
    R := TReader.Create(S, 1024);
    try
      FMainForm.ReadClass;
      R.OnSetName := ReaderSetName;
      R.ReadComponents(Form, Form, ComponentRead);
    finally
      R.Free;
    end;
  finally
    S.Free;
    GlobalUnlock(Data);
  end;
  FMainForm.UpdateControl(psChange);
  fMultiSelected:= False;
end;

procedure TProxyDesigner.ReaderSetName(Reader: TReader; Component: TComponent;
  var Name: string);
begin
   Name := UniqueName(Component.ClassName);
end;

// 嘿咯持扁甫 且 锭 哪欺惩飘狼 困摹客 ComponentState甫 汲沥茄促.
procedure TProxyDesigner.ComponentRead(Component: TComponent);
begin
   TExposeComponent(Component).SetDesigning(True);
   TControl(Component).Left:= TControl(Component).Left + 10;
   TControl(Component).Top:= TControl(Component).Top + 10;
   TProxyForm(Form).SelectControl:= TControl(Component);
   AddComponentList(Component);
   SelectComponent(Component);
end;

procedure TProxyDesigner.ClearGrabHandles;
var
  I,Index:Integer;
begin
  if (fGrabHandles <> nil) then
  begin
     for I:=fGrabList.Count-1 downto 0 do
     begin
        TGrabHandles(fGrabList[I]).Free;
        fGrabList.Delete(I);
     end;
  end;
  fSelectList.Clear;
end;

procedure TProxyDesigner.SelectAll;
var
  I:Integer;
begin
   ClearGrabHandles;
   fMultiSelected:= True;
   with Form do
   begin
     for I:=0 to ComponentCount-1 do
        if (Components[I].ClassType<>TGrabHandle) and
        (Components[I].ClassType<>TWrapperControl) then
           SelectComponent(Components[I]);
   end;
   fMultiSelected:= False;
end;

function TProxyDesigner.IsSelected(Control:TControl): Boolean ;
var
  Index:Integer;
begin
   Index:= fSelectList.IndexOf(Control);
   Result:= (Index  <> -1);
end;

procedure TProxyDesigner.MoveControl(Key:Word);
var
  I:Integer;
begin
   case Key of
      VK_RIGHT:
      begin
         for I:= 0 to fSelectList.Count-1 do
            TControl(fSelectList[I]).Left:= TControl(fSelectList[I]).Left + 1;
         if fSelectList.Count < 5 then UpdateGrabHandle;
      end;
      VK_LEFT:
      begin
         for I:= 0 to fSelectList.Count-1 do
            TControl(fSelectList[I]).Left:= TControl(fSelectList[I]).Left - 1;
         if fSelectList.Count < 5 then UpdateGrabHandle;
      end;
      VK_UP:
      begin
         for I:= 0 to fSelectList.Count-1 do
            TControl(fSelectList[I]).Top:= TControl(fSelectList[I]).Top - 1;
         if fSelectList.Count < 5 then UpdateGrabHandle;
      end;
      VK_DOWN:
      begin
         for I:= 0 to fSelectList.Count-1 do
            TControl(fSelectList[I]).Top:= TControl(fSelectList[I]).Top + 1;
         if fSelectList.Count < 5 then UpdateGrabHandle;
      end;
   end;
end;

procedure TProxyDesigner.SetProxyForm(Value: TCustomForm);
begin
   if Form <> Value then
   begin
     Form:= Value;
     fGrabList.Clear;
     fSelectList.Clear;
     ObjectInspector.InitializeInspector;
     ObjectInspector.DisplayProperty(nil,Form);
   end;
end;

procedure TProxyDesigner.CreateMenuItemComponent(Component: TComponent);
// Menu狼 MenuItem 亲格阑 焊咯霖促.
var
   I, Len, Position: Integer;
   MenuItemLabel: TMenuItemButton;
begin
   if Component = nil then Exit;
   Position:= 0;
   for I:= 0 to TMenu(Component).Items.Count - 1 do
   begin
      MenuItemLabel := TMenuItemButton.Create(Form);
      MenuItemLabel.Caption:= (TMainMenu(Component).Items[I] as TMenuItem).Caption;
      MenuItemLabel.Name:= 'MenuItem'+(TMainMenu(Component).Items[I] as TMenuItem).Name;
      MenuItemLabel.Left:= Position;
      MenuItemLabel.Flat:= True;
      Len:= 8 * Length(MenuItemLabel.Caption) + 1;
      Position:= Position + Len;
      MenuItemLabel.Top:= 0;
      MenuItemLabel.Parent := TWinControl(Form);
   end;
end;

function TProxyDesigner.IsDesignedComponent(Component: TComponent): Boolean;
begin
   Result:= False;
   if (Component is TWrapperControl) or (Component is TMenuItemButton)
      or (Component is TGrabHandle) then
      Result:= True;
end;

procedure TProxyDesigner.SetSelectionList(List: TComponentList);
// Replace SetSelections procedure with SetSelectionList at Delphi 4 or up
var
  I: Integer;
begin
  ClearSelectList;
  if List.Count > 1 then FMultiSelected:= True;
  for I:= 0 to List.Count - 1 do
     SelectComponent(List[I]);
  FMultiSelected:= False;
end;

{ TUndoList }

procedure TUndoList.AddChange(ChangeReason: TUndoType; ChangeList: string);
begin

end;

procedure TUndoList.ClearList;
begin

end;

constructor TUndoList.Create;
begin

end;

destructor TUndoList.Destroy;
begin

end;

function TUndoList.GetCanUndo: Integer;
begin
   Result:= -1;
end;

procedure TUndoList.LockUndo;
begin

end;

procedure TUndoList.RemoveChange(index: Integer);
begin

end;

procedure TUndoList.UnLockUndo;
begin

end;

end.

⌨️ 快捷键说明

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