home *** CD-ROM | disk | FTP | other *** search
/ Softwarová Záchrana 3 / Softwarova-zachrana-3.bin / ArsClip / source.zip / UnitFrmPasteSelected.pas < prev    next >
Pascal/Delphi Source File  |  2003-10-10  |  3KB  |  117 lines

  1. unit UnitFrmPasteSelected;
  2. {
  3.     Purpose:
  4.         Display the clipboard
  5.         User select 0 or more items
  6.         All items are returned as a string - empty if none selected
  7.  
  8.     Updates:
  9.  
  10.         Fixed cancel button
  11.         ------------
  12.  
  13.         Added option to reverse pasting order
  14.         Using UnitClipQueue
  15. }
  16. interface
  17.  
  18. uses
  19.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  20.   Dialogs, StdCtrls;
  21.  
  22. type
  23.   TFrmPasteSelected = class(TForm)
  24.     lbHistory: TListBox;
  25.     btnPaste: TButton;
  26.     btnCancel: TButton;
  27.     cbPasteReverse: TCheckBox;
  28.     procedure FormShow(Sender: TObject);
  29.     procedure btnPasteClick(Sender: TObject);
  30.     procedure btnCancelClick(Sender: TObject);
  31.   private
  32.     { Private declarations }
  33.     Cancelled : boolean;
  34.   public
  35.     { Public declarations }
  36.     function GetSelectedItems() : string;
  37.   end;
  38.  
  39. var
  40.   FrmPasteSelected: TFrmPasteSelected;
  41.  
  42. implementation
  43.  
  44. uses UnitFrmClipboardManager, UnitFrmMainPopup, UnitClipQueue;
  45.  
  46. {$R *.dfm}
  47.  
  48. //----------------------------------
  49. // public interface
  50. //----------------------------------
  51. function TFrmPasteSelected.GetSelectedItems() : string;
  52. var i : longint;
  53.     s : string;
  54. begin
  55.     //
  56.     // We need to steal focus to use this windows after the popup
  57.     // ;otherwise, it will pop-under on the second call
  58.  
  59.     Windows.SetForegroundWindow(self.handle);
  60.     self.ShowModal;
  61.  
  62.     s := '';
  63.     if (not self.Cancelled) then begin
  64.         if cbPasteReverse.Checked then begin
  65.             for i := (lbHistory.items.count - 1) downto 0 do begin
  66.                 if lbHistory.Selected[i] then begin
  67.                     if s = '' then begin
  68.                         s := s + lbHistory.items[i];
  69.                     end else begin
  70.                         s := s + #13#10 + lbHistory.items[i];
  71.                     end;
  72.                 end;
  73.             end;
  74.         end else begin
  75.             for i := 0 to (lbHistory.items.count - 1) do begin
  76.                 if lbHistory.Selected[i] then begin
  77.                     if s = '' then begin
  78.                         s := s + lbHistory.items[i];
  79.                     end else begin
  80.                         s := s + #13#10 + lbHistory.items[i];
  81.                     end;
  82.                 end;
  83.             end;
  84.         end;
  85.     end;
  86.     result := s;
  87. end;
  88.  
  89. //----------------------------------
  90. // private implemenation
  91. //----------------------------------
  92.  
  93. procedure TFrmPasteSelected.FormShow(Sender: TObject);
  94. begin
  95.     // get the latest list
  96.     lbHistory.Items.Clear;
  97.     ClipQueue.GetQueueItems(lbHistory.items);
  98.  
  99. end;
  100.  
  101. procedure TFrmPasteSelected.btnPasteClick(Sender: TObject);
  102. begin
  103.     self.Cancelled := false;
  104.     self.close;
  105. end;
  106.  
  107. procedure TFrmPasteSelected.btnCancelClick(Sender: TObject);
  108. begin
  109.     self.Cancelled := true;
  110.     self.close;
  111. end;
  112.  
  113.  
  114.  
  115.  
  116. end.
  117.