有没有办法在Inno Setup中将字符串复制到剪贴板?
我需要实现一个按钮,将字段的内容复制到剪贴板。
我需要实现一个按钮,将字段的内容复制到剪贴板。
是的,你可以发送 WM_COPY
消息。例如:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Code]
const
WM_COPY = $0301;
var
EditToCopy: TNewEdit;
procedure CopyToClipboard(Control: TWinControl);
begin
SendMessage(Control.Handle, WM_COPY, 0, 0);
end;
procedure ButtonCopyClick(Sender: TObject);
begin
EditToCopy.SelectAll;
CopyToClipboard(EditToCopy);
end;
procedure InitializeWizard;
var
ButtonCopy: TNewButton;
WizardPage: TWizardPage;
begin
WizardPage := CreateCustomPage(wpWelcome, 'Caption', 'Description');
EditToCopy := TNewEdit.Create(WizardForm);
EditToCopy.Parent := WizardPage.Surface;
EditToCopy.Text := 'Text to copy';
ButtonCopy := TNewButton.Create(WizardForm);
ButtonCopy.Parent := WizardPage.Surface;
ButtonCopy.Caption := 'Copy';
ButtonCopy.Top := EditToCopy.Top + EditToCopy.Height + 8;
ButtonCopy.OnClick := @ButtonCopyClick;
end;