YOU CAN CODE!

 

With The Case Of UCanCode.net  Release The Power OF  Visual C++ !   HomeProducts | PurchaseSupport | Downloads  
Download Evaluation
Pricing & Purchase?
E-XD++Visual C++/ MFC Products
Overview
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
Purchase
ActiveX COM Products
Overview
Download
Purchase
Technical Support
  General Q & A
Discussion Board
Contact Us

Links

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++ MFC Example: Sharing file folders using tree control drag & drop
By Sardaukar

A very simple manager for shared file folders using tree control drag & drop

 
 
  • Download demo executable - 13 Kb
  • Download source files - 28 Kb

    Sample Image - ShTree.gif

    Introduction

    This is a very simple shared folder manager that allows you to shared folders by dragging and dropping them onto a tree control.

    Using the control

    Drag a folder from an Explorer window over the tree control to create a new share. The folder will be shared without any control regarding advanced user rights. If the folder is already shared, or you have no rights, or other error occured, an error message will appear. (Keep in mind that the code is NOT very tested - being only a sample -, was developed on Windows2000/MSVC++ 6.0 SP3, and is managing only the local machine. You have to browse the network, fill a combo - or list box - and read currently selected machine from it.)

    All is done by implementing the interface IDropTargetShare, and especially the IDropTargetShare::Drop method. This implementation send WM_DROPFILES message to parent dialog, where DragQueryFile let you identify the number of dropped items, their names, and calls for each NetShareAdd loaded from netapi32.dll. After that, you can simply call in your OnInitDialog (or OnCreate, if you do not use dialogs MDI child windows, for example):

    m_lpDropTarget = new IDropTargetShare;
    if(m_lpDropTarget)
    {
    	HRESULT hr = RegisterDragDrop(m_treeShare.m_hWnd, m_lpDropTarget);
    
    	if(SUCCEEDED(hr))
    		g_cWndCountT++;	//	reference counter - the most primitive idea
    }
    

    In dialog OnDestroy override, RevokeDragDrop revokes the OLE drag-drop registration. Pay attention to OleInitialize call performed in OnInitInstance of CWinApp override to ensure at least a chance for RegisterDragDrop. After that, the interface is responsable with drag and drop. Error handling could be enhanced, but you get the point.

    The tree creation uses a thread routine to fill items. Here is used a structure called SHAREINFO:

    /* sharing information */
    typedef struct _tagSHAREINFO
    {
    	HWND  hwndDlg;
    	HWND  hwndTV;
    	UINT     uThreadId;
    	HANDLE	 hCancelEvent;
    	HANDLE	 hCloseEvent;
    	DWORD   dwUnused;
    	TCHAR lpszMachineName[_MAX_PATH + 1];
    } SHAREINFO, *LPSHAREINFO;
    

    The structure members have, I think, quite self-explanatory names. The events are used to intercept, using WaitForMultipleObjects, OnCancel or OnClose dialog events to terminate the FillShareList thread.

    The deleting of a shared folder is nothing more than a normal using of TVN_BEGINDRAG tree control notification used in conjunction with WM_LBUTTONUP and a boolean flag (m_fDragging) to switch states between ON|OFF dragging states.

    Also, the MultipleShowWindowByDlgId routine helped a lot setting the miriad of statics - it is no more that a simple use of variable-arguments functions. You could use the static control simple manipulation in the About dialog as a simple replacement hyperlink control (to send me an e-mail message).

  •  

     

    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 webmaster@ucancode.net