Type Tform1 =Class(Tform) Memo1: tmemo; ProcedureFormcreate (Sender: tobject ); Private // When the file is dragged to the form, the system will send the wm_drapfiles event to the form, // Therefore, we can obtain the total number of files and file names during wmdropfiles. ProcedureWmdropfiles (VaRMSG: tmessage); message wm_dropfiles; Public {Public declarations} End;
VaR Form1: tform1;
Implementation
{$ R *. DFM}
ProcedureTform1.formcreate (Sender: tobject ); Begin // Enable the file drag-and-drop function when the program starts. When the second parameter is true, // Enable file drag and drop. If it is false, file drag and drop are prohibited. Dragacceptfiles (handle, true ); End;
ProcedureTform1.wmdropfiles (VaRMSG: tmessage ); VaR Filescount: integer; // total number of files I: integer; Filename:Array[0 .. 255]OfChar; Begin Try Memo1.clear; // Obtain the total number of objects Filescount: = dragqueryfile (msg. wparam, $ ffffffff,Nil, 0 ); Memo1.lines. Add ('Total number of files: '+ inttostr (filescount )); // Get the file name ForI: = 0ToFilescount-1Do Begin Dragqueryfile (msg. wparam, I, filename, 256 ); Memo1.lines. Add (filename) End; Finally
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.