Code Samples, Tips, Tricks and |
All Content Copyright © 2000 New Vision Software All rights reserved |
| |
Instance |
Sample Projects by Groups The following are some of my sample projects grouped by type. See House Rules for the rules pertaining to the use of the code contained herein. The samples are all written in VB5 with SP3 installed. If you don't find what you are looking for here, try looking in the All Sample Projects section of this site
ChooseColor Dialog Demo.zip (2KB) This project shows how to call the ChooseColor API function to display a choose color dialog without using the common dialog control. Save And Open File Dialog Demo.zip (7KB) This project shows how to call the GetSaveFileName and GetOpenFileName API functions to display the "Save As..." and "Open" file dialogs without using the common dialog control. It includes the constants for version 5 of the shell (Win2K). It also shows how to implement a hook proc that allows setting of the initial view style for the file list.
CustomDrawLV Demo.zip (5KB) This project shows how to display any row, item or subitem in a listview control in a different color than the rest of the rows by subclassing the NM_CUSTOMDRAW message that is sent to the parent of the listview before each item is drawn. If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. Drag Controls Demo.zip (2KB) This project shows how to easily enable dragging for controls on a VB form at runtime using the SendMessage API function with the WM_NCLBUTTONDOWN and HTCAPTION messages. DragList Demo.zip (10KB) This project shows how to change a standard VB listbox into a drag list style listbox that gives visual feedback when the user drags an item using the mouse. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. EnsureVisible Demo.zip (5KB) This project shows how to use the API to create a simple method for making sure a given control is visible on the screen. The demo uses a MDI interface but the routine can be adapted to just about any situation. LimitEdit Demo.zip (9KB) This project shows how to subclass the WM_CHAR and WM_PASTE messages for an edit control (textbox) to limit the text that can be entered in the control. This technique works well for instances where only numeric input is to be allowed. The LimitEdit object handles several types of numeric entries and can be expanded to handle any type of input limits. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. Linked Listboxes Demo.zip (5KB) This project shows how VB listboxes can be scrolled synchronously as well as positioned to make them appear to be a single list with multiple columns. It also shows how allow the "columns" to be sized at runtime as well as how to simulate header buttons by drawing them yourself. Listbox Columns Demo.zip (2KB) This demo shows how to simulate columns in a standard VB listbox by setting tabstops to the desired positions. MSDE Installer Demo.zip (132 KB) This project shows how you can create a custom installer for installing the Microsoft SQL Server Desktop Engine (MSDE) 2000. The demo shows how to install and configure MSDE using a custom MSI file generated from one of the standard instance files from the MSDE 2K CD. Since this method uses the MSI file from the Microsoft MSDE 2K install, all of the OS version checking and other complexities are handled for you. All you need to worry about is providing an instance name and security info. The demo also shows a method for creating a wizard interface that allows the user to navigate forward and backward through the install dialogs. The demo contains an implementation of a custom command button as well as a progress bar control. PopUp Button Demo.zip (14KB) This project show how to create a popup button using the TrackMouseEvent API function. The button can display both text and graphics. This demo uses all of the modules from the TrackMouseEvent demo and requires Internet Explorer 3.0 or higher. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. PopUp Listbox Demo.zip (35KB) This project shows how you can create a popup virtual listbox similar to the one used for VB's intellisense in the IDE. It is based on Matt Hart's concept of hooking the WM_CREATE message for VB controls to enable changing window styles that can only be set when a control is created. This technique was published in the July, 1999 issue of the VBPJ. I have taken the concept a step further and encapsulated it in a user control. The listbox is also "virtual" in the sense that the items it displays are actually kept in a separate array. The list only calls for the text of an item when it needs to be drawn. This is very useful for situations where you have a large number of items that would require a long time to load into a regular listbox. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. Remove Focused Rect Demo.zip (8KB) This project shows how to remove the focused rectangle (the dotted line around the edge) from VB command buttons. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. Resize Handles Demo.zip (10KB) This project shows how to create 100% API resizing grab handles for a VB control. This allows users to resize controls on your forms at runtime just like you do in the VB IDE. This is implemented as a class object that is very simple to use and that handles everything including resizing the control for you! The 'grab handles' are actually small windows created using the CreateWindowEx API function. No more messing with control arrays of tiny pictureboxes when doing runtime control resizing! This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. Scrollbars (Windows) Demo.zip (15KB) This project implements a class object that will display the standard Windows scrollbars in VB forms, pictureboxes and usercontrols. VB normally keeps these scrollbars hidden but you can bring them out of VB's closet with a few API calls. the difficult part is getting and translating the messages sent from the scrollbars to allow you to scroll items. The class wraps all of the tuff stuff and let's you dump those VB scrollbars with the blinking buttons! This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. Splitter Bar Demo.zip (8KB) This project shows how to create both vertical and horizontal splitter bars to allow resizing of windows within your forms. The demo also shows how you can create an animated splitter like the one used in Books Online. Virtual Listbox Demo.zip (34KB) This project shows how you can create an owner drawn virtual listbox that allows you to set the color of each item to any color you want dynamically. It is based on Matt Hart's concept of hooking the WM_CREATE message for VB controls to enable changing window styles that can only be set when a control is created. This technique was published in the July, 1999 issue of the VBPJ. I have taken the concept a step further and encapsulated it in a user control. The listbox is also "virtual" in the sense that the items it displays are actually kept in a separate array. The list only calls for the text of an item when it needs to be drawn. This is very useful for situations where you have a large number of items that would require a long time to load into a regular listbox. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. Virtual ListView Demo.zip (19KB) This project shows how you can create a fully virtual listview control using the listview in the common controls library. In this context, "virtual" refers to a control that only displays data but doesn't actually store the data that it displays. For instance, you could have data in an array or recordset and display that data in a virtual list without having to add each item to the control. This is accomplished via a callback that occurs each time the control needs to draw one of the items visible in the control. Before each visible item is drawn, the control raises an event to ask for the text that is to be drawn for the given item. This scheme allows you to streamline your code in several ways by allowing you to eliminate duplication of data. So, rather than having a recordset AND a listview that contain the same data, you can just keep the data in the recordset and save the overhead of having to load the duplicate data into the listview. A virtual list is also blindingly fast at displaying large quantities of items. In fact, this demo displays over ONE MILLION items faster than the blink of an eye! Although displaying large amounts of data usually reflects very bad design principals, there are times where there is no way around it. A virtual list handles these situations nicely. The demo is based on Matt Hart's concept of hooking the WM_CREATE message for VB controls to enable changing window styles that can only be set when a control is created. This technique was published in the July, 1999 issue of the VBPJ. I have taken the concept a step further and encapsulated it in a user control. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. What's This Help Demo.zip (5KB) This project shows how simple it is to add "What's This Help" to a VB project. For those unfamiliar with what "What's This Help" is.... It is the context sensitive help provided when the "?" icon is clicked in the title bar of a form that has the WhatsThisButton property set to True. GetLocaleInfo Demo.zip (6KB) This project shows how to return some of the commonly needed system formatting characters like the date and currency separators. It also shows how to create a short date format string that uses a four digit year regardless of the current settings on the system. All of the format retrieval code is wrapped in an easy to use class module. GetTimezoneInfo Demo.zip (4KB) This project shows how to call the GetTimeZoneInformation API function to return the time difference between the local time on the calling machine and Coordinated Universal Time (UTC).
Caption Buttons Demo.zip (8KB) This project implements a class that will draw any of the standard caption buttons on a VB form. You can put a help or minimize button on a tool window or a do just about anything your heart desires with respect to caption buttons. The only thing this class will not do is draw the button on a MDI child form when the child form is maximized (Hey! I had to leave something for you to do!). This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. Caption Buttons Demo (Multi).zip (11KB) This project is an extension of the Caption Buttons Demo above. It handles the drawing of multiple buttons on a single form. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. DrawState Demo.zip (13KB) This project shows how to use the DrawState API function to draw icons and text in a disabled state. The demo also demonstrates how icons can be retrieved from a resource file using the LoadImage API function. Linked Listboxes Demo.zip (5KB) This project shows how VB listboxes can be scrolled synchronously as well as positioned to make them appear to be a single list with multiple columns. It also shows how allow the "columns" to be sized at runtime as well as how to simulate header buttons by drawing them yourself. MDI Background Demo.zip (25KB) This project shows how you can use memory device contexts to create pictures that can be assigned to the picture property of a VB MDI parent form. The project contains routines to stretch a bitmap across the background of the form and center a bitmap on top of a background as well as a routine for tiling a bitmap onto the background. It also contains code to draw transparent bitmaps that is used when overlaying a foreground bitmap onto the background. This project replaces a previous demo that used subclassing to attain a similar result. The routines in this project are generic enough that they can be used with any VB form or control that has a picture property. MSDE Installer Demo.zip (132 KB) This project shows how you can create a custom installer for installing the Microsoft SQL Server Desktop Engine (MSDE) 2000. The demo shows how to install and configure MSDE using the sixteen MSI instance files from an MSDE 2K install. Since this method uses the standard MSI files from the Microsoft MSDE 2K install, all of the OS version checking and other complexities are handled for you. All you need to worry about is providing an instance name and security info. The demo also shows a method for creating a wizard interface that allows the user to navigate forward and backward through the install dialogs. The demo contains an implementation of a custom command button as well as a progress bar control. No_Clipboard_Demo.zip (7KB) This project shows how you can keep the image of a form from being placed on the clipboard by using the clipboard API functions. I do not necessarily recommend the use of this technique since it doesn't play very nicely with bitmap data on the clipboard. The demo is just a response to a question I have seen many times on various forums This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. Option Button Demo.zip (4KB) This project shows how you can draw your own option buttons using either the DrawFrameControl API function or the Marlett font. PopUp Button Demo.zip (14KB) This project show how to create a popup button using the TrackMouseEvent API function. The button can display both text and graphics. This demo uses all of the modules from the TrackMouseEvent demo and requires Internet Explorer 3.0 or higher. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. Remove Focused Rect Demo.zip (8KB) This project shows how to remove the focused rectangle (the dotted line around the edge) from VB command buttons. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE.
DrawState Demo.zip (13KB) This project shows how to use the DrawState API function to draw icons and text in a disabled state. The demo also demonstrates how icons can be retrieved from a resource file using the LoadImage API function. DrawText Path Ellipsis Demo.zip (4KB) This project shows how to use the DrawText API function to alter the length of a string and insert ellipsis (...) in the section of the string where the text was removed. Linked Listboxes Demo.zip (5KB) This project shows how VB listboxes can be scrolled synchronously as well as positioned to make them appear to be a single list with multiple columns. It also shows how allow the "columns" to be sized at runtime as well as how to simulate header buttons by drawing them yourself.
CD Monitor Demo.zip (7KB) This project shows how you can subclass the WM_DEVICECHANGE message to receive notifications when a CD in inserted or removed from a drive on the system. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. CPlApplet Demo.zip (50KB) This project shows how to enumerate and display all of the Control Panel applets on the system. This demo also shows how to implement "flat thunks" from 32bit to 16bit code. See the article on thunking for more details on this subject. DragDrop Files Demo.zip (8KB) This project shows both the API and OLE methods for handling files dropped on a VB application from Windows Explorer or other source. The project also shows how to use OLE dragging to allow files to be dragged from your VB application to other drag targets in the system. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. FindFiles Demo.zip (3KB) This project shows how to use the API to find files as well as how to tell if files exist. The routines are simple and very fast. Parse ASCII URLs Demo.zip (6KB) This project uses the ReadFile API function to read a file containing ASCII text and parse out any URLs without allowing VB to convert the entire file to unicode. This technique would be useful for reading very large files since it uses half of the memory that would be necessary if you used the VB file access functions to read the file into a string. PathFindExtension Demo.zip (4KB) This project shows how to use both the ANSI and the Wide character versions of the PathFindExtension API function to return the extension for a given file. It shows some useful techniques for calling the unicode versions of API functions. Note that IE4 or later must be installed on the system to use this function. Save And Open File Dialog Demo.zip (7KB) This project shows how to call the GetSaveFileName and GetOpenFileName API functions to display the "Save As..." and "Open" file dialogs without using the common dialog control. It includes the constants for version 5 of the shell (Win2K). It also shows how to implement a hook proc that allows setting of the initial view style for the file list. Watch Directory Demo.zip (11KB). This project shows how the FindFirstChangeNotification and FindNextChangeNotification API functions can be used to watch directories and directory trees for changes. This demo implements an API timer to check a series of change notification handles without the serious degradation in performance associated with checking wait handles in a Do...Loop routine.
Caption Buttons Demo.zip (8KB) This project implements a class that will draw any of the standard caption buttons on a VB form. You can put a help or minimize button on a tool window or a do just about anything your heart desires with respect to caption buttons. The only thing this class will not do is draw the button on a MDI child form when the child form is maximized (Hey! I had to leave something for you to do!). This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. Caption Buttons Demo (Multi).zip (11KB) This project is an extension of the Caption Buttons Demo above. It handles the drawing of multiple buttons on a single form. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. Change BorderStyle Demo.zip (3KB) The BorderStyle property of a VB form is read only at runtime. This project shows how to use the SetWindowLong API function to change this property at will at runtime. Form Icon Bug Fix Demo.zip (10KB) This project show how to work around a bug in VB that causes icons in forms to be rendered incorrectly in some cases. This bug appears connected to the video settings on effected machines and only occurs when an Icon containing both 16x16 and 32x32 pixel icons is assigned to the form's Icon property. When the bug manifests itself, it causes a shrunken version of the large icon to be displayed in the titlebar of the form even though a small icon is available. GETMINMAXINFO Demo.zip (5KB) This project shows how to subclass the WM_GETMINMAXINFO message to limit the minimum, maximum and tracking size of a window. HotKey Demo.zip (5KB) This project shows how to use the WM_SETHOTKEY message to set a global hotkey for any form in your VB project. A global hotkey gives users quick access to a window from anywhere in the system. MDI Background Demo.zip (25KB) This project shows how you can use memory device contexts to create pictures that can be assigned to the picture property of a VB MDI parent form. The project contains routines to stretch a bitmap across the background of the form and center a bitmap on top of a background as well as a routine for tiling a bitmap onto the background. It also contains code to draw transparent bitmaps that is used when overlaying a foreground bitmap onto the background. This project replaces a previous demo that used subclassing to attain a similar result. The routines in this project are generic enough that they can be used with any VB form or control that has a picture property. MSDE Installer Demo.zip (132 KB) This project shows how you can create a custom installer for installing the Microsoft SQL Server Desktop Engine (MSDE) 2000. The demo shows how to install and configure MSDE using the sixteen MSI instance files from an MSDE 2K install. Since this method uses the standard MSI files from the Microsoft MSDE 2K install, all of the OS version checking and other complexities are handled for you. All you need to worry about is providing an instance name and security info. The demo also shows a method for creating a wizard interface that allows the user to navigate forward and backward through the install dialogs. The demo contains an implementation of a custom command button as well as a progress bar control. No_Clipboard_Demo.zip (7KB) This project shows how you can keep the image of a form from being placed on the clipboard by using the clipboard API functions. I do not necessarily recommend the use of this technique since it doesn't play very nicely with bitmap data on the clipboard. The demo is just a response to a question I have seen many times on various forums This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. Proxy For Taskbar Demo.zip (5KB) This project shows how to create an API window who's icon will be displayed in the taskbar for a VB form that has no titlebar or caption. Return Value From Modal Form Demo.zip (3KB) This project shows an easy method for returning values from forms that are displayed modally. It takes advantage of the fact that code execution stops on the line of code where the show command is issued until the modally displayed form is either unloaded or hidden. Set Default Menu Item_Demo.zip (3KB) This project shows how to set a bolded, default item in a VB menu using the SetMenuItemInfo API function. Scrollbars (Windows) Demo.zip (15KB) This project implements a class object that will display the standard Windows scrollbars in VB forms, pictureboxes and usercontrols. VB normally keeps these scrollbars hidden but you can bring them out of VB's closet with a few API calls. the difficult part is getting and translating the messages sent from the scrollbars to allow you to scroll items. The class wraps all of the tuff stuff and let's you dump those VB scrollbars with the blinking buttons! This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. Simple Regions Demo.zip (3KB) This project shows how the region API functions can be used to manipulate the portions of forms and controls that will be displayed on the screen. System Menu Demo.zip (8KB) This project shows how you can remove items from the system menu of a form to manipulate the buttons available in the form's title bar. It also shows how to add items to the system menu and how to receive notifications when the added items are selected. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. What's This Help Demo.zip (5KB) This project shows how simple it is to add "What's This Help" to a VB project. For those unfamiliar with what "What's This Help" is.... It is the context sensitive help provided when the "?" icon is clicked in the title bar of a form that has the WhatsThisButton property set to True.
What's This Help Demo.zip (5KB) This project shows how simple it is to add "What's This Help" to a VB project. For those unfamiliar with what "What's This Help" is.... It is the context sensitive help provided when the "?" icon is clicked in the title bar of a form that has the WhatsThisButton property set to True.
DrawState Demo.zip (13KB) This project shows how to use the DrawState API function to draw icons and text in a disabled state. The demo also demonstrates how icons can be retrieved from a resource file using the LoadImage API function. Form Icon Bug Fix Demo.zip (10KB) This project show how to work around a bug in VB that causes icons in forms to be rendered incorrectly in some cases. This bug appears connected to the video settings on effected machines and only occurs when an Icon containing both 16x16 and 32x32 pixel icons is assigned to the form's Icon property. When the bug manifests itself, it causes a shrunken version of the large icon to be displayed in the titlebar of the form even though a small icon is available. PopUp Button Demo.zip (14KB) This project show how to create a popup button using the TrackMouseEvent API function. The button can display both text and graphics. This demo uses all of the modules from the TrackMouseEvent demo and requires Internet Explorer 3.0 or higher. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. Proxy For Taskbar Demo.zip (5KB) This project shows how to create an API window who's icon will be displayed in the taskbar for a VB form that has no titlebar or caption.
CustomDrawLV Demo.zip (5KB) This project shows how to display any row, item or subitem in a listview control in a different color than the rest of the rows by subclassing the NM_CUSTOMDRAW message that is sent to the parent of the listview before each item is drawn. If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. DragList Demo.zip (10KB) This project shows how to change a standard VB listbox into a drag list style listbox that gives visual feedback when the user drags an item using the mouse. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. LimitEdit Demo.zip (9KB) This project shows how to subclass the WM_CHAR and WM_PASTE messages for an edit control (textbox) to limit the text that can be entered in the control. This technique works well for instances where only numeric input is to be allowed. The LimitEdit object handles several types of numeric entries and can be expanded to handle any type of input limits. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. Linked Listboxes Demo.zip (5KB) This project shows how VB listboxes can be scrolled synchronously as well as positioned to make them appear to be a single list with multiple columns. It also shows how allow the "columns" to be sized at runtime as well as how to simulate header buttons by drawing them yourself. Listbox Columns Demo.zip (2KB) This demo shows how to simulate columns in a standard VB listbox by setting tabstops to the desired positions. PopUp Listbox Demo.zip (35KB) This project shows how you can create a popup virtual listbox similar to the one used for VB's intellisense in the IDE. It is based on Matt Hart's concept of hooking the WM_CREATE message for VB controls to enable changing window styles that can only be set when a control is created. This technique was published in the July, 1999 issue of the VBPJ. I have taken the concept a step further and encapsulated it in a user control. The listbox is also "virtual" in the sense that the items it displays are actually kept in a separate array. The list only calls for the text of an item when it needs to be drawn. This is very useful for situations where you have a large number of items that would require a long time to load into a regular listbox. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. Virtual Listbox Demo.zip (34KB) This project shows how you can create an owner drawn virtual listbox that allows you to set the color of each item to any color you want dynamically. It is based on Matt Hart's concept of hooking the WM_CREATE message for VB controls to enable changing window styles that can only be set when a control is created. This technique was published in the July, 1999 issue of the VBPJ. I have taken the concept a step further and encapsulated it in a user control. The listbox is also "virtual" in the sense that the items it displays are actually kept in a separate array. The list only calls for the text of an item when it needs to be drawn. This is very useful for situations where you have a large number of items that would require a long time to load into a regular listbox. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. Virtual ListView Demo.zip (19KB) This project shows how you can create a fully virtual listview control using the listview in the common controls library. In this context, "virtual" refers to a control that only displays data but doesn't actually store the data that it displays. For instance, you could have data in an array or recordset and display that data in a virtual list without having to add each item to the control. This is accomplished via a callback that occurs each time the control needs to draw one of the items visible in the control. Before each visible item is drawn, the control raises an event to ask for the text that is to be drawn for the given item. This scheme allows you to streamline your code in several ways by allowing you to eliminate duplication of data. So, rather than having a recordset AND a listview that contain the same data, you can just keep the data in the recordset and save the overhead of having to load the duplicate data into the listview. A virtual list is also blindingly fast at displaying large quantities of items. In fact, this demo displays over ONE MILLION items faster than the blink of an eye! Although displaying large amounts of data usually reflects very bad design principals, there are times where there is no way around it. A virtual list handles these situations nicely. The demo is based on Matt Hart's concept of hooking the WM_CREATE message for VB controls to enable changing window styles that can only be set when a control is created. This technique was published in the July, 1999 issue of the VBPJ. I have taken the concept a step further and encapsulated it in a user control. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE.
Menu Columns Demo.zip (4KB) This project shows how to ad vertical column separators to VB menus using the Menu API functions. Set Default Menu Item_Demo.zip (3KB) This project shows how to set a bolded, default item in a VB menu using the SetMenuItemInfo API function. System Menu Demo.zip (8KB) This project shows how you can remove items from the system menu of a form to manipulate the buttons available in the form's title bar. It also shows how to add items to the system menu and how to receive notifications when the added items are selected. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. TrackPopUpMenu_Demo.zip (3KB) This project shows how to use some of the menu API functions to create an API popup menu that can be displayed using the TrackPopupMenu API function. This technique is especially useful if you have a MDI Child form that needs to display a popup menu but you don't want the menus on the MDI Child to override the menus on the MDI Parent.
Capture Mouse Demo.zip (3K) This project shows how you can use the SetCapture API function to know when the mouse leaves the area of a given control. See the TrackMouseEvent Demo farther down on this page for a more correct but also more complicated method for determining when the mouse leaves the client area of a control. TrackMouseEvent Demo.zip (7KB) This project shows how to use the TrackMouseEvent API function which is the "correct" method to use for determining when the mouse leaves or hovers over the client area of a given control or form. The project implements a class that raises both events (MouseHover & MouseLeave) and is quite easy to use. Requires Internet Explorer 3.0 or higher. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE.
Subclass Demo (Basic).zip (5KB) This project explains the concept of subclassing windows messages and includes a basic routine for subclassing in Visual Basic. While the code sample in this project will work in VB applications, a more robust routine that allows breaking in the IDE is preferred. This project is targeted at those who are just beginning to explore subclassing to allow them to "get their feet wet" and get a better understanding of the concept before moving on to more complex subclassing schemes. See Subclass Demo (Advanced).zip for a more robust subclassing routine. Subclass Demo (Advanced).zip (7KB) This project implements advanced subclassing techniques that allow for multiple instances of the subclassing object as well as the use of a "debug" dll to make setting breakpoints in the IDE without crashing possible while subclassed. If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE.
Parse ASCII URLs Demo.zip (6KB) This project uses the ReadFile API function to read a file containing ASCII text and parse out any URLs without allowing VB to convert the entire file to unicode. This technique would be useful for reading very large files since it uses half of the memory that would be necessary if you used the VB file access functions to read the file into a string. PathFindExtension Demo.zip (4KB) This project shows how to use both the ANSI and the Wide character versions of the PathFindExtension API function to return the extension for a given file. It shows some useful techniques for calling the unicode versions of API functions. Note that IE4 or later must be installed on the system to use this function.
DragList Demo.zip (10KB) This project shows how to change a standard VB listbox into a drag list style listbox that gives visual feedback when the user drags an item using the mouse. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. MSDE Installer Demo.zip (132 KB) This project shows how you can create a custom installer for installing the Microsoft SQL Server Desktop Engine (MSDE) 2000. The demo shows how to install and configure MSDE using the sixteen MSI instance files from an MSDE 2K install. Since this method uses the standard MSI files from the Microsoft MSDE 2K install, all of the OS version checking and other complexities are handled for you. All you need to worry about is providing an instance name and security info. The demo also shows a method for creating a wizard interface that allows the user to navigate forward and backward through the install dialogs. The demo contains an implementation of a custom command button as well as a progress bar control. PopUp Button Demo.zip (14KB) This project show how to create a popup button using the TrackMouseEvent API function. The button can display both text and graphics. This demo uses all of the modules from the TrackMouseEvent demo and requires Internet Explorer 3.0 or higher. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. PopUp Listbox Demo.zip (35KB) This project shows how you can create a popup virtual listbox similar to the one used for VB's intellisense in the IDE. It is based on Matt Hart's concept of hooking the WM_CREATE message for VB controls to enable changing window styles that can only be set when a control is created. This technique was published in the July, 1999 issue of the VBPJ. I have taken the concept a step further and encapsulated it in a user control. The listbox is also "virtual" in the sense that the items it displays are actually kept in a separate array. The list only calls for the text of an item when it needs to be drawn. This is very useful for situations where you have a large number of items that would require a long time to load into a regular listbox. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. Virtual Listbox Demo.zip (34KB) This project shows how you can create an owner drawn virtual listbox that allows you to set the color of each item to any color you want dynamically. It is based on Matt Hart's concept of hooking the WM_CREATE message for VB controls to enable changing window styles that can only be set when a control is created. This technique was published in the July, 1999 issue of the VBPJ. I have taken the concept a step further and encapsulated it in a user control. The listbox is also "virtual" in the sense that the items it displays are actually kept in a separate array. The list only calls for the text of an item when it needs to be drawn. This is very useful for situations where you have a large number of items that would require a long time to load into a regular listbox. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. Virtual ListView Demo.zip (19KB) This project shows how you can create a fully virtual listview control using the listview in the common controls library. In this context, "virtual" refers to a control that only displays data but doesn't actually store the data that it displays. For instance, you could have data in an array or recordset and display that data in a virtual list without having to add each item to the control. This is accomplished via a callback that occurs each time the control needs to draw one of the items visible in the control. Before each visible item is drawn, the control raises an event to ask for the text that is to be drawn for the given item. This scheme allows you to streamline your code in several ways by allowing you to eliminate duplication of data. So, rather than having a recordset AND a listview that contain the same data, you can just keep the data in the recordset and save the overhead of having to load the duplicate data into the listview. A virtual list is also blindingly fast at displaying large quantities of items. In fact, this demo displays over ONE MILLION items faster than the blink of an eye! Although displaying large amounts of data usually reflects very bad design principals, there are times where there is no way around it. A virtual list handles these situations nicely. The demo is based on Matt Hart's concept of hooking the WM_CREATE message for VB controls to enable changing window styles that can only be set when a control is created. This technique was published in the July, 1999 issue of the VBPJ. I have taken the concept a step further and encapsulated it in a user control. This demo uses subclassing techniques so, If you don't already have it, you will want to get the Debug Object (Dbgwproc.dll) DLL to allow stepping through subclassed code in break mode in the VB IDE. If you don't find what you are looking for on this page, try looking in the All Sample Projects section of this site. |