VCL controls that can support file drag
Support for file drag in some places special use, such as playing software playlists, playing windows, they all support file drag operations, which lays a foundation for the simplicity of the program, and I have written before How to make the program support file dragging articles, but now in order to make your own program more convenient to write, I have written three components that support files that support files TzqdragfilesListbox, TDQDragfileschecklistbox, TzqdragfilePanel, can see from their names. Its use, these components are inheriting existing VCL components, I just let them support the drag of files, if you want to know how to implement, you can refer to my article "to implement files with the program Move support, in order to verify the effective line of these components I wrote, I also made a simple player that supported file drag, the program interface is as follows:
Simple player supported by file drag
The above applet uses the two components of TzqdragfilesListbox and TzqDragfilePanel, you can drag the media format files supported by MediaPlayer to the playback window and playlist. Here is the key statement of this program using the two components, as follows:
// Drag the media file to be played directly to the play window.
Void __fastcall tform1 :: zqdragfilepanel1dragfile (TOBJECT * SENDER,
Ansistring filename)
{
/ / Add it to the playlist
ZqdragfilesListBox1-> items-> add (filename);
PlayMedia (filename);
}
// Drag the media file to be played to the playlist
Void __fastcall tform1 :: zqdragfileslistbox1dragfiles (TOBJECT * SENDER,
Tstringlist * filenames)
{
ZqdragfilesListBox1-> items-> addstrings (filenames);
IF (MediaPlayer1-> Wait)
{
// Play the current media file in the playlist
Ansistring filename = zqdragfileslistbox1-> items-> strings [zqdragfileslistbox1-> itMindex];
PlayMedia (filename);
}
}
/ / PlayMedia function definition:
Void __fastcall tform1 :: PlayMedia (ANSISSIING FileName)
{
// Todo: Add your source code here
MediaPlayer1-> filename = filename;
MediaPlayer1-> open ();
/ / Here to pay attention to setting the statement of MediaPlayer's DisplayRect in MediaPlayer1-> Open () statement
After //, because the DisplayRect of the MediaPlayer must be valid after MEDIA Device is turned on.
MediaPlayer1-> DisplayRect = zqdragfilepanel1-> clientRect;
MediaPlayer1-> Play ();
}
About the source program of this program You can download it to http://www.zccfamily.com/zqget/Web website, and you can also download the source program of these components!