Sunday, August 24, 2008

Client Program That Uses Directory List And File List

This program uses two ActiveX controls: a 'Dir' control and a 'Filelist' control. Creation of these controls has been discussed in the first two articles of the section 'ActiveX' in this same site. We have created the a dialog-based project called 'client' using MFC AppWizard. To use the ActiveX controls they have to be registered with the Windows registry. If you want to register these controls on your machine you will have to download these controls from the first two articles in the section 'ActiveX' on this site. Once registered these controls can be inserted in the dialog box. using the following procedure: From the 'Project' menu select 'Add To Project' then select 'Components and Controls'. A dialog box will be popped up. Open 'Registered ActiveX Controls' folder. Search for the control to be inserted; in our case 'Dir' control and 'Filelist' control. Double click on both the controls to insert them in the project. The bitmaps of these controls would now be visible in the 'Controls' toolbar of the dialog editor. Pick both and paste them side by side. You can see the preview of both in the dialog box. The dialog that we created is shown in Figure 1. Run the application to see the effect. The two controls are independent of one another. Our client program helps them to interact. When we select any directory from the 'Dir' control our client program recieves an event with full path of the selected directory. The client program then calls SetPath( ) and SetFormat( ) functions of the 'Filelist' control. Hence whenever we select the directory from the 'Dir' control the files present in the specified directory are listed in 'Filelist' control. When we click on the filename from the 'Filelist' control our client program recieves an event with full path of the selected filename which is then displayed in the edit box.

No comments:

Your Title