📄 oleregister11.pas
字号:
//========================= OLE UI UTILITIES ===================================
//
// This is s component editor for the OleConvertDialog component
//
// Grahame Marsh
// Freeware for UNDU - you get it for free I make no promises
// gsmarsh@aol.com
//------------------------------------------------------------------------------
{$I OLE.INC}
unit OleRegister11;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ComCtrls, ExtCtrls, ActiveX, ExtDlgs,
OleConsts, OleDlgs, OleHelpers;
type
TOleConvertForm = class(TForm)
PageControl: TPageControl;
StandardTabSheet: TTabSheet;
GroupBox2: TGroupBox;
Label4: TLabel;
Label5: TLabel;
CaptionEdit: TEdit;
CentreCheckBox: TCheckBox;
ResourceEdit: TEdit;
GroupBox3: TGroupBox;
ConvertOnlyCheckBox: TCheckBox;
HelpCheckBox: TCheckBox;
DisableActivateCheckBox: TCheckBox;
DisableDisplayIconCheckBox: TCheckBox;
HideChangeIconCheckBox: TCheckBox;
IsLinkCheckBox: TCheckBox;
SelectRG: TRadioGroup;
FormatsTabSheet: TTabSheet;
Label1: TLabel;
FormatComboBox: TComboBox;
AspectRadioGroup: TRadioGroup;
ExcludeTabSheet: TTabSheet;
GroupBox4: TGroupBox;
CLSIDListView: TListView;
TestBtn: TBitBtn;
DelBtn: TBitBtn;
AddBtn: TBitBtn;
EditExcludeBitBtn: TBitBtn;
BrowseCLSIDBitBtn: TBitBtn;
OKBtn: TBitBtn;
CancelBtn: TBitBtn;
TabSheet1: TTabSheet;
Label2: TLabel;
CLSIDEdit: TEdit;
GroupBox1: TGroupBox;
ConvertCheckBox: TCheckBox;
ConvertCLSIDEdit: TEdit;
GroupBox5: TGroupBox;
ActivateCheckBox: TCheckBox;
ActivateCLSIDEdit: TEdit;
GroupBox6: TGroupBox;
LoadBitBtn: TBitBtn;
ClearBitBtn: TBitBtn;
ImagePanel: TPanel;
MFImage: TImage;
UserTypeEdit: TEdit;
Label3: TLabel;
Label6: TLabel;
IconEdit: TEdit;
OpenPictureDialog: TOpenPictureDialog;
procedure AddBtnClick(Sender: TObject);
procedure BrowseCLSIDBitBtnClick(Sender: TObject);
procedure DelBtnClick(Sender: TObject);
procedure EditExcludeBitBtnClick(Sender: TObject);
procedure TestBtnClick(Sender: TObject);
procedure LoadBitBtnClick(Sender: TObject);
procedure ClearBitBtnClick(Sender: TObject);
private
FComponent : TComponent;
public
property Dialog : TComponent read FComponent write FComponent;
procedure Initialise;
procedure Finalise;
end;
var
OleConvertForm: TOleConvertForm;
implementation
{$R *.DFM}
uses
OleRegister8;
procedure TOleConvertForm.Initialise;
var
Loop : integer;
Copy : TUIMetafile;
begin
with FComponent as TOleConvertDialog do
begin
// Standard tab
CentreCheckBox.Checked := AutoCentre;
CaptionEdit.Text := Caption;
HelpCheckBox.Checked := ShowHelp;
ResourceEdit.Text := Resource;
SelectRG.ItemIndex := ord (Select);
ConvertOnlyCheckBox.Checked := ConvertOnly;
DisableActivateCheckBox.Checked := DisableActivateAs;
DisableDisplayIconCheckBox.Checked := DisableDisplayAsIcon;
HideChangeIconCheckBox.Checked := HideChangeIcon;
IsLinkCheckBox.Checked := IsLinked;
// CLSID tab
CLSIDEdit.Text := CLSID;
ConvertCheckBox.Checked := ConvertDefault.Active;
ConvertCLSIDEdit.Text := ConvertDefault.CLSID;
ActivateCheckBox.Checked := ActivateDefault.Active;
ActivateCLSIDEdit.Text := ActivateDefault.CLSID;
// Format Tab
FormatComboBox.Items.AddStrings (KnownClipboardFormats);
FormatComboBox.Text := Format.Name;
case Format.Aspect of
caContent : AspectRadioGroup.ItemIndex := 0;
caIcon : AspectRadioGroup.ItemIndex := 1
else
AspectRadioGroup.ItemIndex := -1
end;
UserTypeEdit.Text := UserType;
IconEdit.Text := IconLabel;
if not Metafile.Empty then
begin
Copy := TUIMetafile.Create;
Copy.Assign (Metafile);
MFImage.Picture.Graphic := Copy;
ImagePanel.Caption := ''
end else
ImagePanel.Caption := '(empty)';
// Exclude tab
for Loop := 0 to Exclude.Count - 1 do
with CLSIDListView.Items.Add do
Caption := Exclude [Loop]
end
end;
procedure TOleConvertForm.Finalise;
var
Loop : integer;
begin
with FComponent as TOleConvertDialog do
begin
// Standard tab
AutoCentre := CentreCheckBox.Checked;
Caption := CaptionEdit.Text;
ShowHelp := HelpCheckBox.Checked;
Resource := ResourceEdit.Text;
Select := TConvertSelect (SelectRG.ItemIndex);
ConvertOnly := ConvertOnlyCheckBox.Checked;
DisableActivateAs := DisableActivateCheckBox.Checked;
DisableDisplayAsIcon := DisableDisplayIconCheckBox.Checked;
HideChangeIcon := HideChangeIconCheckBox.Checked;
IsLinked := IsLinkCheckBox.Checked;
// Format & Metafile
Format.Name := FormatComboBox.Text;
if AspectRadioGroup.ItemIndex = 0 then
Format.Aspect := caContent
else
Format.Aspect := caIcon;
UserType := UserTypeEdit.Text;
IconLabel := IconEdit.Text;
if Assigned (MFImage.Picture) then
Metafile.Assign (MFImage.Picture.Graphic)
else
Metafile.Assign (nil);
// CLSID tab
CLSID := CLSIDEdit.Text;
ConvertDefault.Active := ConvertCheckBox.Checked;
ConvertDefault.CLSID := ConvertCLSIDEdit.Text;
ActivateDefault.Active := ActivateCheckBox.Checked;
ActivateDefault.CLSID := ActivateCLSIDEdit.Text;
// Exclude tab
Exclude.Clear;
for Loop := 0 to CLSIDListView.Items.Count - 1 do
Exclude.Add (CLSIDListView.Items[Loop].Caption)
end
end;
//--- Exclude Page -------------------------------------------------------------
// Add a new CLSID - offer a null CLSID to edit
procedure TOleConvertForm.AddBtnClick(Sender: TObject);
begin
with CLSIDListView.Items.Add do
begin
Caption := '{00000000-0000-0000-0000-000000000000}';
EditCaption
end
end;
//--- Delete the selected CLSID
procedure TOleConvertForm.DelBtnClick(Sender: TObject);
begin
with CLSIDListView do
if Assigned (Selected) then
Selected.Delete
end;
//--- Put the listview into edit mode
procedure TOleConvertForm.EditExcludeBitBtnClick(Sender: TObject);
begin
with CLSIDListView do
if Assigned (Selected) then
Selected.EditCaption
end;
//--- Test each CLSID for the correct format (doesn't mean they right,
// just in the format like '{69857C20-AA5A-11D2-9803-C65433F0DB60}'
procedure TOleConvertForm.TestBtnClick(Sender: TObject);
var
Loop : integer;
CLSID : TCLSID;
Bad : boolean;
begin
Bad := false;
with CLSIDListView do
for Loop := 0 to Items.Count - 1 do
if CLSIDFromString (PWideChar(WideString(Items[Loop].Caption)), CLSID) <> NOERROR then
begin
ShowMessage (Items[Loop].Caption + ' is invalid');
Bad := true
end;
if not Bad then
ShowMessage ('All CLSIDs are valid')
end;
//--- read the registry to pick a CLSID
procedure TOleConvertForm.BrowseCLSIDBitBtnClick(Sender: TObject);
begin
with TBrowseCLSIDForm2.Create (Application) do
try
ConversionMode;
if Assigned (CLSIDListView.Selected) then
SelectedCLSID := CLSIDListView.Selected.Caption;
if ShowModal = mrOk then
if Assigned (CLSIDListView.Selected) then
CLSIDListView.Selected.Caption := SelectedCLSID
else
CLSIDListView.Items.Add.Caption := SelectedCLSID
finally
Free
end
end;
procedure TOleConvertForm.LoadBitBtnClick(Sender: TObject);
var
M : TUIMetafile;
begin
with OpenPictureDialog do
begin
if Execute then
begin
M := TUIMetafile.Create;
M.LoadFromFile (Filename);
MFImage.Picture.Graphic := M;
if Assigned (MFImage.Picture) then
ImagePanel.Caption := ''
else
ImagePanel.Caption := '(empty)'
end
end
end;
procedure TOleConvertForm.ClearBitBtnClick(Sender: TObject);
begin
ImagePanel.Caption := '(empty)';
MFImage.Picture := nil
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -