home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Softwarová Záchrana 3
/
Softwarova-zachrana-3.bin
/
ArsClip
/
source.zip
/
UnitFrmPasteSelected.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
2003-10-10
|
3KB
|
117 lines
unit UnitFrmPasteSelected;
{
Purpose:
Display the clipboard
User select 0 or more items
All items are returned as a string - empty if none selected
Updates:
Fixed cancel button
------------
Added option to reverse pasting order
Using UnitClipQueue
}
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TFrmPasteSelected = class(TForm)
lbHistory: TListBox;
btnPaste: TButton;
btnCancel: TButton;
cbPasteReverse: TCheckBox;
procedure FormShow(Sender: TObject);
procedure btnPasteClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
private
{ Private declarations }
Cancelled : boolean;
public
{ Public declarations }
function GetSelectedItems() : string;
end;
var
FrmPasteSelected: TFrmPasteSelected;
implementation
uses UnitFrmClipboardManager, UnitFrmMainPopup, UnitClipQueue;
{$R *.dfm}
//----------------------------------
// public interface
//----------------------------------
function TFrmPasteSelected.GetSelectedItems() : string;
var i : longint;
s : string;
begin
//
// We need to steal focus to use this windows after the popup
// ;otherwise, it will pop-under on the second call
Windows.SetForegroundWindow(self.handle);
self.ShowModal;
s := '';
if (not self.Cancelled) then begin
if cbPasteReverse.Checked then begin
for i := (lbHistory.items.count - 1) downto 0 do begin
if lbHistory.Selected[i] then begin
if s = '' then begin
s := s + lbHistory.items[i];
end else begin
s := s + #13#10 + lbHistory.items[i];
end;
end;
end;
end else begin
for i := 0 to (lbHistory.items.count - 1) do begin
if lbHistory.Selected[i] then begin
if s = '' then begin
s := s + lbHistory.items[i];
end else begin
s := s + #13#10 + lbHistory.items[i];
end;
end;
end;
end;
end;
result := s;
end;
//----------------------------------
// private implemenation
//----------------------------------
procedure TFrmPasteSelected.FormShow(Sender: TObject);
begin
// get the latest list
lbHistory.Items.Clear;
ClipQueue.GetQueueItems(lbHistory.items);
end;
procedure TFrmPasteSelected.btnPasteClick(Sender: TObject);
begin
self.Cancelled := false;
self.close;
end;
procedure TFrmPasteSelected.btnCancelClick(Sender: TObject);
begin
self.Cancelled := true;
self.close;
end;
end.