Drag your software to open a file

Source: Internet
Author: User

Drag your software to open a file

Author: Shuai hongjun

// Statement

Protected
Procedure wmdropfiles (var msg: tmessage); message wm_dropfiles;

Bytes ------------------------------------------------------------------------------------------------------------------------

// Implementation

Procedure tformmain. wmdropfiles (var msg: tmessage );
VaR
I, n: integer;
Buffer: array [0 .. 255] of char;
Begin
// Obtain the number of drag files
N: = dragqueryfile (msg. wparam, $ ffffffff, buffer, 255 );

// Process multiple selected files
For I: = 0 to n-1 do
Begin
// Obtain the drag Object Name
Dragqueryfile (msg. wparam, I, buffer, and 255 );

// The file name is in the buffer.
If uppercase (extractfileext (buffer) = '. bzlx' then
Begin
// Determine whether the file has been opened
If uppercase (buffer) = uppercase ('test. bzlx') then
Begin
Messagedlg ('the file test. bzlx has been opened! ', (Mtinformation), [mbok], 0 );
Exit;
End;

// Open the file
Openfile (buffer );

Exit;
End;
End;

// End dragging
Dragfinish (msg. wparam );
End;

Bytes ------------------------------------------------------------------------------------------------------------------------

// Initialization

Procedure tformmain. formcreate (Sender: tobject );
Begin
// Enable the window handle to receive the drag operation

Dragacceptfiles (handle, true );

End;

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.