File drag effect-C ++ implementation

Source: Internet
Author: User

The following is my simple implementation ..

 

I created an mfc project .. The Interface contains a listbox .. Member variable: m_list.

Add: this-> DragAcceptFiles (TRUE) in OnInitDialog );

 

Add a WM_DROPFILES message to this dialog box ..

Message Processing functions:

Void CdrayFilesDlg: OnDropFiles (HDROP hDropInfo) {// TODO: add the message processing program code and/or call the default UINT uFileNum =: DragQueryFile (hDropInfo, 0 xffffffffff, NULL, 0); WCHAR strFileName [MAX_PATH]; for (int I = 0; I <uFileNum; I ++) {: DragQueryFileW (hDropInfo, I, strFileName, MAX_PATH ); CString str (strFileName); m_list.AddString (str + "\ r \ n"); }:: DragFinish (hDropInfo); CDialogEx: OnDropFiles (hDropInfo);} void CdrayFilesDlg :: onDropFiles (HDROP hDropInfo) {// TODO: add the message processing program code here and/or call the default UINT uFileNum =: DragQueryFile (hDropInfo, 0 xffffffff, NULL, 0 ); WCHAR strFileName [MAX_PATH]; for (int I = 0; I <uFileNum; I ++) {: DragQueryFileW (hDropInfo, I, strFileName, MAX_PATH ); CString str (strFileName); m_list.AddString (str + "\ r \ n"); }:: DragFinish (hDropInfo); CDialogEx: OnDropFiles (hDropInfo );}


In this way, you can implement the drag function .. I didn't expect it to be that simple ..

 

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.