With The Case Of  Release The Power OF  Visual C++ !   HomeProducts | PurchaseSupport | Downloads  
Download Evaluation
Pricing & Purchase?
E-XD++Visual C++/ MFC Products
Features Tour 
Electronic Form Solution
Visualization & HMI Solution
Power system HMI Solution
CAD Drawing and Printing Solution

Bar code labeling Solution
Workflow Solution

Coal industry HMI Solution
Instrumentation Gauge Solution

Report Printing Solution
Graphical modeling Solution
GIS mapping solution

Visio graphics solution
Industrial control SCADA &HMI Solution
BPM business process Solution

Industrial monitoring Solution
Flowchart and diagramming Solution
Organization Diagram Solution

Graphic editor Source Code
UML drawing editor Source Code
Map Diagramming Solution

Architectural Graphic Drawing Solution
Request Evaluation
ActiveX COM Products
Technical Support
  General Q & A
Discussion Board
Contact Us


Get Ready to Unleash the Power of UCanCode .NET


UCanCode Software focuses on general application software development. We provide complete solution for developers. No matter you want to develop a simple database workflow application, or an large flow/diagram based system, our product will provide a complete solution for you. Our product had been used by hundreds of top companies around the world!

"100% source code provided! Free you from not daring to use components because of unable to master the key technology of components!"

VC++ Code: Drag and Drop File in Dialog with WM_DROPFILES and WM_NCLBUTTONDOWN



Here is a simple method to have a Drag and Drop feature in our dialog based applications. To provide Drag and Drop we have a windows Message Handler called WM_DROPFILES. Handle this message through ON_MESSAGE message map to capture the dropped files.

Message Handler

Collapse Copy Code
 BEGIN_MESSAGE_MAP(CComGuidFinderDlg, CDialog)
  ON_MESSAGE(WM_DROPFILES,OnDropFiles)// Message Handler for Drang and Drop

Now its time to handle the WM_DROPFILES messages through a user defined method. The function prototype should be like this

Collapse Copy Code
  LRESULT  OnDropFiles(WPARAM wParam,LPARAM lParam);

Finally we have a function to capture the drop events. The wParam is a handle to the HDROP structure describing the dropped files. To get the info about the dropped file i.e. the file name used :-

Collapse Copy Code
 DragQueryFile(hDrop,    // Struture Identifier
        -1,        // -1 to Drop more than one file or ( integer 0 to max )
                   // to drop selected No of files
        szDroppedFile,// Droped File Name
        MAX_PATH);   // Max char 

So now we did all possible coding in our dialog based application to handle Drag & Drop feature. But still it is handicapped. Handling the Drop event is not enough to ensure the Drag & Drop feature. We need to register our window to accept the dropped file using

Collapse Copy Code
  BOOL CComGuidFinderDlg::OnInitDialog()
    DragAcceptFile(TRUE) // To Accept Dropped file Set this TRUE

Good... That's all and we have done well!

I added one more feature in this sample i.e. Moving the our dialog by clicking on anywhere on the window. This can be do by posting WM_NCLBUTTONDOWN message to HTCAPTION Handle this statement in OnLButtonDownMessage(...)

Collapse Copy Code




Copyright ?1998-2022 UCanCode.Net Software , all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.

Please direct your questions or comments to