code : pascal
unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, ExtCtrls, jpeg, OleCtrls, SHDocVw; type TForm1 = class(TForm) Image1: TImage; ListBox1: TListBox; WebBrowser1: TWebBrowser; procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } // mendeklarasikan procedure acceptfiles procedure AcceptFiles(var msg: TMessage); message WM_DROPFILES; end; var Form1: TForm1; implementation uses // menginclude shellapi ke programShellAPI;
{$R *.DFM} procedure TForm1.AcceptFiles(var msg: TMessage); const cnMaxFileNameLen = 255; var i, nCount: integer; acFileName: array[0..cnMaxFileNameLen] of char; begin // menghitung jumlah file yang di drag nCount := DragQueryFile(msg.WParam, $FFFFFFFF, acFileName, cnMaxFileNameLen); // pengulangan jumlah file yang di blok for i := 0 to nCount - 1 do begin DragQueryFile(msg.WParam, i, acFileName, cnMaxFileNameLen); // memasukan alamat file yang didrag ke listbox ListBox1.Items.Add(acFileName); end; //jika ingin menampilkan gambar gunakan //image1.Picture.LoadFromFile(acFileName); //jika ingin menampilkan web gunakan//WebBrowser1.Navigate(acFileName);
DragFinish(msg.WParam); end; procedure TForm1.FormCreate(Sender: TObject); begin // mengijinkan file untuk di drag di form DragAcceptFiles(Handle, True); end; end.Parsed in 0.013 seconds, using GeSHi
// sintak ini masih bisa kita kembangkan untuk membuka file bertipe lain serti Txt Dan Lain Sebagainya
| | read more HERE | Print |
[ read more ] |