1. unit Unit1;
2. interface
3. uses
4. Windows, Messages, SysUtils, Classes,
5. Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, ExtCtrls, jpeg,
6. OleCtrls, SHDocVw;
7. type
8. TForm1 = class(TForm)
9. Image1: TImage;
10. ListBox1: TListBox;
11. WebBrowser1: TWebBrowser;
12. procedure FormCreate(Sender: TObject);
13. private
14. { Private declarations }
15. public
16. { Public declarations }
17. // mendeklarasikan procedure acceptfiles
18. procedure AcceptFiles(var msg: TMessage);
19. message WM_DROPFILES;
20. end;
21. var
22. Form1: TForm1;
23. implementation
24. uses
25. // menginclude shellapi ke program
26. ShellAPI;
27. {$R *.DFM}
28. procedure TForm1.AcceptFiles(var msg: TMessage);
29. const
30. cnMaxFileNameLen = 255;
31. var
32. i,
33. nCount: integer;
34. acFileName: array[0..cnMaxFileNameLen] of char;
35. begin
36. // menghitung jumlah file yang di drag
37. nCount := DragQueryFile(msg.WParam,
38. $FFFFFFFF,
39. acFileName,
40. cnMaxFileNameLen);
41. // pengulangan jumlah file yang di blok
42. for i := 0 to nCount - 1 do
43. begin
44. DragQueryFile(msg.WParam, i,
45. acFileName, cnMaxFileNameLen);
46. // memasukan alamat file yang didrag ke listbox
47. ListBox1.Items.Add(acFileName);
48. end;
49. //jika ingin menampilkan gambar gunakan
50. //image1.Picture.LoadFromFile(acFileName);
51. //jika ingin menampilkan web gunakan
52. //WebBrowser1.Navigate(acFileName);
53. DragFinish(msg.WParam);
54. end;
55.
56. procedure TForm1.FormCreate(Sender: TObject);
57. begin
58. // mengijinkan file untuk di drag di form
59. DragAcceptFiles(Handle, True);
60. end;
61. end.
2. interface
3. uses
4. Windows, Messages, SysUtils, Classes,
5. Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, ExtCtrls, jpeg,
6. OleCtrls, SHDocVw;
7. type
8. TForm1 = class(TForm)
9. Image1: TImage;
10. ListBox1: TListBox;
11. WebBrowser1: TWebBrowser;
12. procedure FormCreate(Sender: TObject);
13. private
14. { Private declarations }
15. public
16. { Public declarations }
17. // mendeklarasikan procedure acceptfiles
18. procedure AcceptFiles(var msg: TMessage);
19. message WM_DROPFILES;
20. end;
21. var
22. Form1: TForm1;
23. implementation
24. uses
25. // menginclude shellapi ke program
26. ShellAPI;
27. {$R *.DFM}
28. procedure TForm1.AcceptFiles(var msg: TMessage);
29. const
30. cnMaxFileNameLen = 255;
31. var
32. i,
33. nCount: integer;
34. acFileName: array[0..cnMaxFileNameLen] of char;
35. begin
36. // menghitung jumlah file yang di drag
37. nCount := DragQueryFile(msg.WParam,
38. $FFFFFFFF,
39. acFileName,
40. cnMaxFileNameLen);
41. // pengulangan jumlah file yang di blok
42. for i := 0 to nCount - 1 do
43. begin
44. DragQueryFile(msg.WParam, i,
45. acFileName, cnMaxFileNameLen);
46. // memasukan alamat file yang didrag ke listbox
47. ListBox1.Items.Add(acFileName);
48. end;
49. //jika ingin menampilkan gambar gunakan
50. //image1.Picture.LoadFromFile(acFileName);
51. //jika ingin menampilkan web gunakan
52. //WebBrowser1.Navigate(acFileName);
53. DragFinish(msg.WParam);
54. end;
55.
56. procedure TForm1.FormCreate(Sender: TObject);
57. begin
58. // mengijinkan file untuk di drag di form
59. DragAcceptFiles(Handle, True);
60. end;
61. end.
0 Komentar