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

📄 _dcreg.pas

📁 DiskControls.v3.8.Full.Source 控制磁盘的控件 包括源代码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
   begin
    Dialog := TdcOpenDialog.Create(Application);
    with Dialog do
    try
      InitialDirSaver.RegKey := dcOpenDialogRegKey + TComponent(Component).Name;
      if Component.ClassName = 'TdcFileInfo' then
        FileName := TdcFileInfo(Component).FileName
      else
       if Component.ClassName = 'TdcVersionInfo' then
         FileName := TdcVersionInfo(Component).FileName;
      Filter     := 'All files (*.*)|*.*';
      Options    := Options + [ofHideReadOnly, ofNoDereferenceLinks];
      if Execute then
       begin
        if Component.ClassName = 'TdcFileInfo' then
          TdcFileInfo(Component).FileName := FileName
        else
         if Component.ClassName = 'TdcVersionInfo' then
           TdcVersionInfo(Component).FileName := FileName;
        Designer.Modified;
       end;
    finally
      Free;
    end;
   end
  else
   if Index = 1 then
    dcShowAbout(Component.ClassName);
end;

function TdcFileInfoCompEditor.GetVerbCount: Integer;
begin
  Result := inherited GetVerbCount + 2;
end;

function TdcFileInfoCompEditor.GetVerb(Index: Integer): String;
begin
  if Index = 0 then
    Result := '&Select File...'
  else
    if Index = 1 then
      Result := '&About...';  
end;

{$IFDEF D5}
procedure TdcFileInfoCompEditor.PrepareItem(Index: Integer; const AItem: IMenuItem);
begin
  {$IFNDEF D6}
  if (Index = GetVerbCount - 2) then
    AItem.Bitmap.LoadFromResourceName(hInstance, 'DCLOAD')
  else
   if (Index = GetVerbCount - 1) then
     AItem.Bitmap.LoadFromResourceName(hInstance, 'DCABOUT')
   else
  {$ENDIF} 
     inherited PrepareItem(Index, AItem)
end;
{$ENDIF}


{$IFDEF D3}
// dcShellIcon Component Editor
procedure TdcShellIconCompEditor.ExecuteVerb(Index: Integer);
var
  Dialog: TdcOpenDialog;
begin
  if Index = 0 then
   begin
    Dialog := TdcOpenDialog.Create(Application);
    with Dialog do
    try
      InitialDirSaver.RegKey := dcOpenDialogRegKey + TComponent(Component).Name;    
      FileName   := TdcShellIcon(Component).FileName;
      Filter     := 'All files (*.*)|*.*';
      Options    := Options + [ofHideReadOnly, ofNoDereferenceLinks];
      if Execute then
       begin
        TdcShellIcon(Component).FileName := FileName;
        Designer.Modified;
       end;
    finally
      Free;
    end;
   end
  else
   if Index = 1 then
    dcShowAbout(Component.ClassName);
end;

function TdcShellIconCompEditor.GetVerbCount: Integer;
begin
  Result := inherited GetVerbCount + 2;
end;

function TdcShellIconCompEditor.GetVerb(Index: Integer): String;
begin
  if Index = 0 then
    Result := '&Select File...'
  else
    if Index = 1 then
      Result := '&About...';  
end;

{$IFDEF D5}
procedure TdcShellIconCompEditor.PrepareItem(Index: Integer; const AItem: IMenuItem);
begin
  {$IFNDEF D6}
  if (Index = GetVerbCount - 2) then
    AItem.Bitmap.LoadFromResourceName(hInstance, 'DCLOAD')
  else
   if (Index = GetVerbCount - 1) then
     AItem.Bitmap.LoadFromResourceName(hInstance, 'DCABOUT')
   else
  {$ENDIF}
     inherited PrepareItem(Index, AItem)
end;
{$ENDIF}


// dcShellLink Component Editor
procedure TdcShellLinkCompEditor.ExecuteVerb(Index: Integer);
var
  Dialog: TdcOpenDialog;
begin
  if Index = 0 then
   begin
    Dialog := TdcOpenDialog.Create(Application);
    with Dialog do
    try
      InitialDirSaver.RegKey := dcOpenDialogRegKey + TComponent(Component).Name;    
      FileName   := TdcShellLink(Component).FileName;
      Filter     := 'Shortcut files (*.lnk)|*.lnk|All files (*.*)|*.*';
      Options    := Options + [ofHideReadOnly, ofNoDereferenceLinks];
      if Execute then
       begin
        TdcShellLink(Component).FileName := FileName;
        Designer.Modified;
       end;
    finally
      Free;
    end;
   end
  else
   if Index = 1 then
    dcShowAbout(Component.ClassName);
end;

function TdcShellLinkCompEditor.GetVerbCount: Integer;
begin
  Result := inherited GetVerbCount + 2;
end;

function TdcShellLinkCompEditor.GetVerb(Index: Integer): String;
begin
  if Index = 0 then
    Result := '&Select Shell Link...'
  else
    if Index = 1 then
      Result := '&About...';  
end;

{$IFDEF D5}
procedure TdcShellLinkCompEditor.PrepareItem(Index: Integer; const AItem: IMenuItem);
begin
  {$IFNDEF D6}
  if (Index = GetVerbCount - 2) then
    AItem.Bitmap.LoadFromResourceName(hInstance, 'DCLOAD')
  else
   if (Index = GetVerbCount - 1) then
     AItem.Bitmap.LoadFromResourceName(hInstance, 'DCABOUT')
   else
  {$ENDIF} 
     inherited PrepareItem(Index, AItem)
end;
{$ENDIF}


// dcShellItem Component Editor
procedure TdcShellItemCompEditor.ExecuteVerb(Index: Integer);
begin
  if Index = 0 then
    dcShowAbout(Component.ClassName)
  else
   if Index = 2 then
     TdcShellProperties(Component).ShowProperties
   else
    if Index = 3 then
      TdcShellProperties(Component).ShowContextMenu;
end;

function TdcShellItemCompEditor.GetVerbCount: Integer;
begin
  Result := inherited GetVerbCount + 4;
end;

function TdcShellItemCompEditor.GetVerb(Index: Integer): String;
begin
  if Index = 0 then
    Result := '&About...'
  else
   if Index = 1 then
     Result := '-'
   else
    if Index = 2 then
      Result := 'Test Show&Properties...'
    else
     if Index = 3 then
       Result := 'Test Show&ContextMenu >';
end;

{$IFDEF D5}
procedure TdcShellItemCompEditor.PrepareItem(Index: Integer; const AItem: IMenuItem);
begin
  {$IFNDEF D6}
  if (Index = GetVerbCount - 4) then
    AItem.Bitmap.LoadFromResourceName(hInstance, 'DCABOUT')
  else
   if (Index = GetVerbCount - 2) then
     AItem.Bitmap.LoadFromResourceName(hInstance, 'DCLIGHT')
   else
    if (Index = GetVerbCount - 1) then
      AItem.Bitmap.LoadFromResourceName(hInstance, 'DCLIGHT')
    else
  {$ENDIF}
      inherited PrepareItem(Index, AItem)
end;
{$ENDIF}


// MultiDiskScanner editors
{ IncludeList Property Editor }
procedure TdcDiskScannerIncludeListProperty.Edit;
begin
  ShowMultiDiskScannerDesigner(Designer, TdcMultiDiskScanner(GetComponent(0)), False);
end;

function TdcDiskScannerIncludeListProperty.GetValue: String;
var
  i: Integer;
begin
  i := TdcMultiDiskScanner(GetComponent(0)).IncludeList.Count;
  if i = 0 then
   Result := '(None)'
  else
   if i = 1 then
    Result := '(1 include)'
   else
    Result := '(' + IntToStr(i) + ' includes)'
end;

function TdcDiskScannerIncludeListProperty.GetAttributes: TPropertyAttributes;
begin
  Result := [paDialog];
end;


{ ExcludeList Property Editor }
procedure TdcDiskScannerExcludeListProperty.Edit;
begin
  ShowMultiDiskScannerDesigner(Designer, TdcMultiDiskScanner(GetComponent(0)), True);
end;

function TdcDiskScannerExcludeListProperty.GetValue: String;
var
  I: Integer;
begin
  I := TdcMultiDiskScanner(GetComponent(0)).ExcludeList.Count;
  if I = 0 then
    Result := '(None)'
  else
   if I = 1 then
     Result := '(1 exclude)'
   else
     Result := '(' + IntToStr(I) + ' excludes)'
end;

function TdcDiskScannerExcludeListProperty.GetAttributes: TPropertyAttributes;
begin
  Result := [paDialog];
end;


{ Component Editor }
procedure TdcDiskScannerFilesCompEditor.ExecuteVerb(Index: Integer);
begin
  if Index = 3 then
    ShowMultiDiskScannerDesigner(Designer, TdcMultiDiskScanner(Component), False)
  else
   if Index = 2 then
     ShowMultiDiskScannerDesigner(Designer, TdcMultiDiskScanner(Component), True)
   else
    if Index = 0 then
      dcShowAbout(Component.ClassName);
end;

function TdcDiskScannerFilesCompEditor.GetVerbCount: Integer;
begin
  Result := inherited GetVerbCount + 4;
end;

function TdcDiskScannerFilesCompEditor.GetVerb(Index: Integer): String;
begin
  if Index = 3 then
    Result := '&IncludeList Designer...'
  else
   if Index = 2 then
     Result := '&ExcludeList Designer...'
   else
    if Index = 1 then
      Result := '-'
    else
     if Index = 0 then
       Result := '&About...';
end;

{$IFDEF D5}
procedure TdcDiskScannerFilesCompEditor.PrepareItem(Index: Integer; const AItem: IMenuItem);
begin
  {$IFNDEF D6}
  if (Index = GetVerbCount - 1) then
    AItem.Bitmap.LoadFromResourceName(hInstance, 'DCTOOL')
  else
   if (Index = GetVerbCount - 2) then
     AItem.Bitmap.LoadFromResourceName(hInstance, 'DCTOOL')
   else
    if (Index = GetVerbCount - 4) then
      AItem.Bitmap.LoadFromResourceName(hInstance, 'DCABOUT')
    else
  {$ENDIF}  
      inherited PrepareItem(Index, AItem)
end;
{$ENDIF}
{$ENDIF}


procedure Register;
begin
  RegisterComponents('Disk Controls', [TdcDiskScanner,
                                       TdcMultiDiskScanner,
                                       TdcFileOperations,
                                       TdcFolderMonitor,
                                       TdcFileAssociation,
                                       TdcVirtualDrives,
                                       TdcDiskInfo,
                                       TdcFileInfo,
                                       TdcFileCRC,
                                       TdcFileTail,
                                       TdcVersionInfo,
{$IFDEF D3}
                                       TdcShellIcon,
                                       TdcShellLink,
                                       TdcShellProperties,
{$ENDIF}
                                       TdcFolderListView,
                                       TdcFileEdit,
{$IFDEF D3}                                       
                                       TdcFolderEdit,
{$ENDIF}                                       
                                       TdcOpenDialog,
                                       TdcSaveDialog,
{$IFDEF D3}
                                       TdcOpenPictureDialog,
                                       TdcSavePictureDialog,
                                       TdcBrowseDialog,                                       
{$ENDIF}
                                       TdcSystemImageList,
                                       TdcIcon2Bitmap]);

  RegisterComponentEditor(TumdcComponent, TdcComponentEditor);
{$IFDEF D3}
  RegisterComponentEditor(TdcMultiDiskScanner, TdcDiskScannerFilesCompEditor);
  RegisterComponentEditor(TdcVirtualDrives, TdcVirtualDrivesCompEditor);
{$ENDIF}  
  RegisterComponentEditor(TdcFileInfo, TdcFileInfoCompEditor);
  RegisterComponentEditor(TdcFileCRC, TdcFileInfoCompEditor);
  RegisterComponentEditor(TdcVersionInfo, TdcFileInfoCompEditor);
{$IFDEF D3}
  RegisterComponentEditor(TdcShellIcon, TdcShellIconCompEditor);
  RegisterComponentEditor(TdcShellLink, TdcShellLinkCompEditor);
  RegisterComponentEditor(TdcShellProperties, TdcShellItemCompEditor);
{$ENDIF}  
  RegisterComponentEditor(TdcFolderListView, TdcComponentEditor);
  RegisterComponentEditor(TdcFileEdit, TdcComponentEditor);
{$IFDEF D3}
  RegisterComponentEditor(TdcFolderEdit, TdcComponentEditor);
{$ENDIF}  
  RegisterComponentEditor(TdcOpenDialog, TdcComponentEditor);
  RegisterComponentEditor(TdcSaveDialog, TdcComponentEditor);
{$IFDEF D3}
  RegisterComponentEditor(TdcOpenPictureDialog, TdcComponentEditor);
  RegisterComponentEditor(TdcSavePictureDialog, TdcComponentEditor);
{$ENDIF}  
  RegisterComponentEditor(TdcSystemImageList, TdcComponentEditor);

  RegisterPropertyEditor(TypeInfo(String), TumdcComponent, 'About', TdcAboutProperty);
  RegisterPropertyEditor(TypeInfo(String), TdcSystemImageList, 'About', TdcAboutProperty);
  RegisterPropertyEditor(TypeInfo(String), TdcFileEdit, 'About', TdcAboutProperty);
  RegisterPropertyEditor(TypeInfo(String), TdcFileEdit, 'DlgFilter', TFilterProperty);
  RegisterPropertyEditor(TypeInfo(TCaption), TdcFileEdit, 'Text', TdcFileNameProperty);
{$IFDEF D3}
  RegisterPropertyEditor(TypeInfo(String), TdcFolderEdit, 'About', TdcAboutProperty);
  RegisterPropertyEditor(TypeInfo(TCaption), TdcFolderEdit, 'Text', TdcFolderProperty);
{$ENDIF}    
  RegisterPropertyEditor(TypeInfo(String), TdcFolderListView, 'About', TdcAboutProperty);
{$IFDEF D3}
  RegisterPropertyEditor(TypeInfo(String), TdcFolderListView, 'Folder', TdcFolderProperty);
{$ENDIF}    
  RegisterPropertyEditor(TypeInfo(String), TdcOpenDialog, 'About', TdcAboutProperty);
  RegisterPropertyEditor(TypeInfo(String), TdcSaveDialog, 'About', TdcAboutProperty);
{$IFDEF D3}
  RegisterPropertyEditor(TypeInfo(String), TdcOpenPictureDialog, 'About', TdcAboutProperty);
  RegisterPropertyEditor(TypeInfo(String), TdcSavePictureDialog, 'About', TdcAboutProperty);
{$ENDIF}  
  RegisterPropertyEditor(TypeInfo(String), TdcFileTail, 'FileName', TdcFileNameProperty);
  RegisterPropertyEditor(TypeInfo(String), TdcFileInfo, 'FileName', TdcFileNameProperty);
  RegisterPropertyEditor(TypeInfo(String), TdcFileCRC, 'FileName', TdcFileNameProperty);
  RegisterPropertyEditor(TypeInfo(String), TdcFileAssociation, 'ExecutableFile', TdcFileNameProperty);
  RegisterPropertyEditor(TypeInfo(String), TdcFileAssociation, 'IconFile', TdcFileNameProperty);    
  RegisterPropertyEditor(TypeInfo(String), TdcVersionInfo, 'FileName', TdcFileNameProperty);
{$IFDEF D3}
  RegisterPropertyEditor(TypeInfo(String), TdcShellIcon, 'FileName', TdcFileNameProperty);
  RegisterPropertyEditor(TypeInfo(String), TdcShellLink, 'FileName', TdcLinkFileNameProperty);
  RegisterPropertyEditor(TypeInfo(String), TdcShellLink, 'LinkTarget', TdcFileNameProperty);
  RegisterPropertyEditor(TypeInfo(String), TdcShellProperties, 'FileName', TdcFileNameProperty);
{$ENDIF}  
  RegisterPropertyEditor(TypeInfo(String), TdcRegistrySaver, 'IniFileName', TdcFileNameProperty);
{$IFDEF D3}
  RegisterPropertyEditor(TypeInfo(String), TdcOpenDialog, 'InitialDir', TdcFolderProperty);
{$ENDIF}  
  RegisterPropertyEditor(TypeInfo(TFileName), TdcOpenDialog, 'FileName', TdcFileNameProperty);
{$IFDEF D3}
  RegisterPropertyEditor(TypeInfo(String), TdcSaveDialog, 'InitialDir', TdcFolderProperty);
{$ENDIF}
  RegisterPropertyEditor(TypeInfo(TFileName), TdcSaveDialog, 'FileName', TdcFileNameProperty);
{$IFDEF D3}
  RegisterPropertyEditor(TypeInfo(String), TdcOpenPictureDialog, 'InitialDir', TdcFolderProperty);
  RegisterPropertyEditor(TypeInfo(TFileName), TdcOpenPictureDialog, 'FileName', TdcFileNameProperty);
  RegisterPropertyEditor(TypeInfo(String), TdcSavePictureDialog, 'InitialDir', TdcFolderProperty);
  RegisterPropertyEditor(TypeInfo(TFileName), TdcSavePictureDialog, 'FileName', TdcFileNameProperty);
  RegisterPropertyEditor(TypeInfo(String), TdcBrowseDialog, 'Folder', TdcFolderProperty);
  RegisterPropertyEditor(TypeInfo(String), TdcDiskScanner, 'Folder', TdcFolderProperty);
  RegisterPropertyEditor(TypeInfo(String), TdcFolderMonitor, 'Folder', TdcFolderProperty);
  RegisterPropertyEditor(TypeInfo(String), TdcVirtualDrives, 'Target', TdcFolderProperty);
  RegisterPropertyEditor(TypeInfo(String), TdcFileOperations, 'DestFolder', TdcFolderProperty);
  RegisterPropertyEditor(TypeInfo(TList), TdcMultiDiskScanner, 'IncludeList', TdcDiskScannerIncludeListProperty);
  RegisterPropertyEditor(TypeInfo(TList), TdcMultiDiskScanner, 'ExcludeList', TdcDiskScannerExcludeListProperty);
{$ENDIF}  
end;

end.

⌨️ 快捷键说明

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