Is there any way to copy a string to the clipboard with Inno Setup?
有没有办法使用Inno Setup将字符串复制到剪贴板?
I need to implement a button to copy the contents of a field to clipboard.
我需要实现一个按钮来将字段的内容复制到剪贴板。
1 个解决方案
#1
Yes, you can send the WM_COPY
message. For example:
是的,您可以发送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;
#1
Yes, you can send the WM_COPY
message. For example:
是的,您可以发送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;