 |
Further
Reading ...
|
|
Doing Your Holiday Shopping On Ebay. Most people do far more shopping in the holiday season than they do for the rest of the year - and now you know how to use eBay, why not do it there? If you know what kind of thing your friends and family like then eBay's categories are ideal places...
2much.net Defuses Code Bombs 2much.net Overcomes Time Bombs (Montreal) December 2, 2004 – 2much.net has overcome the Time Bombs planted in its operating systems and is back online, a week earlier than anticipated. The company, recently hit by cyber sabotage and theft of...
5 Steps To Get Top 10 Website Search Engine Rank 1. Step One: Select right keyword for web SEO Optimization. You must choose your keywords carefully. This is the most important step of the SEO. Wrong or ineffective keywords mean invalid keyword optimization. You should find popular keywords and...
How to understand the Domain Name System Ever wonder why DNS systems came into existence? Efficiency. Every computer has a distinct IP address, and the Internet needed an elite method for obtaining these addresses and for managing the system as a whole. Enter ICANN. The Internet...
|
|
|
Creating a Windows Explorer clone with complete shell browsing GUI in your Visual C++ MFC application with Shell MegaPack ActiveX
|
 |
Written By:
Atul Godbole
|
|
|
Creating a Windows Explorer clone with complete shell browsing GUI in your Visual C++ MFC application with Shell MegaPack ActiveX
Original article at http://www.ssware.com/articles/creating-explorer-clone-in-visualc++-mfc.htm Link : Original Article
Introduction
Any developer who has ever wanted to provide file/folder browsing or file-selection functionality in his own application knows the utter lack of simple, extensible and customizable MFC components for this purpose.
Even as simple a task such as letting the user select a folder has to be accomplished by using complex shell programming APIs like SHBrowseForFolder. And all you get after all this is exactly the ability to let a user select a folder. The disadvantages of this approach, apart from the fact that it is very inflexible and non-customizable, is that this approach shows a modal dialog to the user, meaning the user has to deal with the dialog before moving on - either select the folder or cancel the operation.
Another option is to use the 'common dialogs' - the MFC CFileDialog class - which is almost as inflexible and narrow-minded in its goals and features. Sure it can be extended to add more controls, but only after you have spent 20 hours wrestling with subclassing and hooks and WindowProc.
To do away with the modal madness, you can a listbox and combobox in your own own dialog and use an API like the DlgDirList to list all drives, directories or files. All you get with these APIis is a textual list of filenames. Compare this to Windows Explorer which shows the entire shell's namespace including filesystem items and virtual items like Control Panel, Network Neighborhood etc in all their glory - with pretty icons, a hierarchical display of folders, Thumbnail or Details or Group Views, infotips, dragdrop, context menus, etc.
And with Shell MegaPack, you can get all this in your application. If you want drop-in Windows Explorer shell browsing functionality in your own application, with all features of Windows Explorer's features, along with the advanced behavior control and customization, and you want all of this with minimal time and effort, then Shell MegaPack is the way to go.
Inserting the controls in your dialog.
To insert the ActiveX controls in your MFC project, right click on the dialog at design time and select 'Insert ActiveX Control..'. In the dialog box that comes up, select 'Sky Software FolderView ActiveX Control" and click 'OK'. Repeat this procedure for FileView and ShComboBox. Now that all three controls are on your dialog, position and size the controls as per your needs and give them the desired IDs.
Next, we will add variables for all the three controls. To do so, right-click on the FileView control at design-time and select 'ClassWizard..'. Select the 'Member Variables' tab, select the ID for the FileView control in the 'Control IDs' listbox and click 'Add Variable..'. At this stage, Visual C++ will ask whether it should generate wrapper classes for the control. Click 'OK' and give the control the desired variable name and click 'OK again'. Repeat this step for the other two controls as well.
Setting properties
All three controls can be fully customized at design-time. To set properties, right click on the controls at design time and - continued below ...
|
|
|
continued ...
select 'Sky Software FolderView ActiveX Control Object' --> 'Properties..'. This will bring up the property pages from where you can customize the controls as per your needs. You can change the appearance and colors, set filtering modes (hide virtual items, hide hidden items, show folders), set the starting folder, set whether context menus, infotips, etc are shown and whether dragdrop is allowed. Almost every aspect of the controls can be customized at design time in this way.
Linking the controls together
Linking the three controls with each other enables them to synchronize automatically with each other. For example, if a new folder is selected in FolderView, FileView will automatically update itself to show the contents of that folder. Linking can be done in just 2 lines of code :
m_shCmbBox.SetFolderView((LPDISPATCH)m_fldrVw.GetControlUnknown()); m_fldrVw.SetFileView((LPDISPATCH)m_fileVw.GetControlUnknown());
Event Handling and behavior control
The controls come with a large number events which are fired when certain things occur, such as when the current folder has changed or an item has been clicked or double-clicked or selected or checked. The other use of events is to give you the opportunity to do advanced customization. For example, you might want to allow the display of context menus for one item but not another, or allow dropping of files on some particular folders or disallow execution of some files. Simply setting Cancel = True in the proper event allows you to accomplish this.
To handle an event, right click on the control at design time and select the 'Events..' menu item. In the dialog that comes up, select the appropriate event and click 'Add and Edit'. For example, to prevent display of context menus for folders, handle the OnItemRightClick event of FileView and use the following code :
CListItem i; i.AttachDispatch(Item,FALSE); if(i.GetAttributes(FOLDER) & FOLDER) *Cancel=TRUE;
Advanced customization
The controls allow you to replace or extend the default attributes of items. You can change the display names (text) of files and folders ( for example, prefix an asterisk(*) before all files ), change the default icons shown for files and folders, add, remove or modify items from the context menu of files and folders, add custom columns in Details View. You can even add your own custom items to the controls. With this feature, you can recreate an entire shell namespace extension within your own application with minimal effort.
Conclusion
A Windows Explorer like shell browsing UI is required in many applications, yet there is no simple way to add such functionality in your application without spending countless hours for the most basic functionality. If you desire even a little semblance to the explorer UI and a little customization, then the corresponding time required grows exponentially. Shell MegaPack brings a drop-in shell browsing UI to your app within minutes and shields you from all the complexities and pains and the modal madness discussed above. Just the gains in terms of the time saved is more than worth it.
About the Author
Atul Godbole is the President of Sky Software, a leading developer of user interface components based on ActiveX and .Net technologies. To contact him or to find more information about Sky Software and its products, please visit http://www.ssware.com.
|
|
|
|
 |
|
|
| _Additional Resources ... |



|
The Advantages And Disadvantages Of Buying On Ebay. The Case For.
Whatever you want to buy, whether it's large or small, cheap or expensive, everyday or just plain weird, the chances are you can find it on eBay. It's the largest auction site in the world, and when it comes to the variety of what's...
Adult Web Hosting: The all you need to know What sort of web hosting options should you go for if you want to host an adult website? You need to remember that this is the most critical aspect of your adult website. Facts like shared or dedicated adult web hosting, the maximum allowed...
Researching Informationto Develop Your Unique Content We live in a sea of information. And information overload is an increasingly common complaint. Part of the complaint arises because we get hit with different headlines that point to the same content. So we waste time on things that have no added...
|
|
|
|
|
|
 |
|
|
|