![]() |
Brad's VB-32 Programs & Samples |
|
| Posted: 09/17/97, last update: 03/12/99 | ||
| EnumDeskVB: Dynamically
create both the treeview and listview common controls at runtime This example is busy. Not only does it create both the treeview and listview common controls at runtime through the API (no Comctl32.ocx); subclass the controls' parent window, a VB Form, allowing the receipt of control window notification messages; implement both the IShellFolder interface, and IShellFolder's child interface, the IEnumIDList interface while processing the notifications; it also enumerates the shell's namespace and displays the names and icons of any and all file system objects in each control. Other interesting Explorer-like behavior is thrown in, including right-click context menu functionality with help from the IContextMenu interface, and for good measure, a deceivingly simple little splitter bar is used to simultaneously adjust the size of both control windows within the Form. Other various (and subtle) Explorer-like functionality is also demonstrated. This VB example is based on, and ported directly from, the EnumDesk C example found in the Microsoft Developer's Network Premium library and in Nancy Cluts' book "Programming the Windows 95 User Interface" from the Microsoft Press. Due to the relative complexity of the C example, some interesting tricks were employed in order to get the code to work in VB. Not only is the IUnknown interface used directly in place of VB's "Set" statement, but memory pointers to everything, including interface object references, structures (VB Types), strings and anything else, are thrown around by the MoveMemory (AKA CopyMemory) function as frequently as variables are Dim'd. For the sake of completeness, the example includes the *entire* complement of treeview, listview and imagelist C definitions and macros converted to VB code (with the exception of CustomDraw), and contains some rather handy general purpose error, string, shell, and window procedure debugging code. The source code is fairly heavily documented as well. 03/12/99, Revision 2: It's been exactly a year and a half from its initial release, and this demo has finally been completely rewritten and extensively updated. All known bugs have been corrected, and fair amount of new functionality has been added. See demo's _Readme.txt file for more information. 09/17/97, initial release Download edeskvb2.zip (149kb) |