How can my application receive a notification when the clipboard text changes?
For example:
I would to enable/disable a paste button and setting its Hint property in order to display the clipboard's text (like 'Paste "%s"')
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TMyPasteForm = class(TForm)
MyPasteButton: TButton;
MyEdit: TEdit;
procedure MyPasteButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
procedure SyncMyPasteButton();
{ Private declarations }
public
{ Public declarations }
end;
var
MyPasteForm: TMyPasteForm;
implementation
{$R *.dfm}
uses
Clipbrd;
procedure TMyPasteForm.FormCreate(Sender: TObject);
begin
MyPasteButton.ShowHint := True;
end;
procedure TMyPasteForm.MyPasteButtonClick(Sender: TObject);
begin
MyEdit.Text := Clipboard.AsText;
end;
procedure TMyPasteForm.SyncMyPasteButton();
begin
MyPasteButton.Enabled := Length(Clipboard.AsText) > 0;
MyPasteButton.Hint := Format('Paste "%s"', [Clipboard.AsText]);
end;
end.