Sunday, August 24, 2008

Directory Copy Control

Frequently we wish to build a control which copies one directory to another. The standard 'File' dialog is not of much use here since it cannot be used as a control inside another dialog. Also the standard 'File' dialog permits selection of only files and not of directories. To meet this requirement we have developed here an ActiveX directory control. We have used the 'MFC ActiveX Control Wizard' to develop the dircopy control. The steps involved are enumerated below:

  1. Select 'MFC ActiveX Control Wizard' as new project type with project name as 'DirCopy'. Click on 'OK'.

  2. In Step 1 of 2 select '1' for 'How many controls would you like your project to have?'. Click on 'Next'. Click on 'Finish' to let the wizard generate the code.

Next we have added an OnCreate( ) handler to the CDirCopyCtrl class. From the OnCreate( ) handler we have made a provision to create tooltips. For more information on tooltips to an activex control see 'ToolTips to an activx control' in the same website. and then we have laoded a bitmap. In OnDraw( ) handler we have built the folder bitmap using BitBlt( ) . We have added OnLButtonDown( ) handler to CDirCopyCtrl. In this handler we have written a code for popping up a copy dialog, so whenever we click left mouse button on the folder bitmap a copy dialog gets popped up. This dilaog box contains two edit boxes one for source and another for target directory. We can also browse for the directoy using the 'Browse' button present on the copy dialog . Whenever we click on the 'Browse' button 'dirdialog' gets popped up and helps you to browse the directory from the treeview control. After browsing both the directory paths we can click on copy button to copy the directory.

No comments:

Your Title