home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programming Unleashed / Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso / misc / draglist / main.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-03-21  |  1.3 KB  |  60 lines

  1. unit Main;
  2.  
  3. { Program copyright (c) 1995 by Charles Calvert }
  4. { Project Name: DRAGLIST }
  5.  
  6. { Use Drag and Drop to drag text from a listbox to
  7.   an edit control. }
  8.    
  9. interface
  10.  
  11. uses
  12.   SysUtils, WinTypes, WinProcs,
  13.   Messages, Classes, Graphics,
  14.   Controls, Forms, Dialogs,
  15.   StdCtrls;
  16.  
  17. type
  18.   TForm1 = class(TForm)
  19.     Edit1: TEdit;
  20.     ListBox1: TListBox;
  21.     Label1: TLabel;
  22.     procedure FormKeyDown(Sender: TObject; var Key: Word;
  23.       Shift: TShiftState);
  24.     procedure Edit1DragOver(Sender, Source: TObject; X, Y: Integer;
  25.       State: TDragState; var Accept: Boolean);
  26.     procedure Edit1DragDrop(Sender, Source: TObject; X, Y: Integer);
  27.   private
  28.     { Private declarations }
  29.   public
  30.     { Public declarations }
  31.   end;
  32.  
  33. var
  34.   Form1: TForm1;
  35.  
  36. implementation
  37.  
  38. {$R *.DFM}
  39.  
  40. procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  41.   Shift: TShiftState);
  42. begin
  43.   if ssAlt in Shift then
  44.     if Key = vk_Tab then
  45.       Edit1.Text := 'Bingo';
  46. end;
  47.  
  48. procedure TForm1.Edit1DragOver(Sender, Source: TObject; X, Y: Integer;
  49.   State: TDragState; var Accept: Boolean);
  50. begin
  51.   Accept := True;
  52. end;
  53.  
  54. procedure TForm1.Edit1DragDrop(Sender, Source: TObject; X, Y: Integer);
  55. begin
  56.   Edit1.Text := (Source as TListBox).ITems.Strings[ListBox1.ItemIndex];
  57. end;
  58.  
  59. end.
  60.