Common Control Routines
Updated Monday December 26, 2011
   
Category
Topic
Initialization
vb6
vb5
vb4-32
InitCommonControlsEx: Common Control Initialization Module
This file will be required to be added to the existing project for all common control API methods detailed here that use the API to actually create the common control (as opposed to using the Visual Basic Common Control). The BAS module will provide the mechanism to initialize the comctl32.dll, regardless of the version installed.


Header API
vb6
vb5
vb4-32
CreateWindowEx: Create the Common Control Header
Using the comctl32 header APIs to create a header control you can reposition over any control. Implements the Common Control Initialization module detailed above.

WM_NOTIFY: Detect Sizing Notifications from a ListView ColumnHeader
Detect column resizing, header repositioning, clicks and double clicks on the ListView header. Aug 22.1999



ListView
vb6
vb5
vb4-32
SendMessage: ListView API Messages, Styles, and Notifications
Definitions of the various ListView members in commctrl.h.

ListView Demo Project
A four part demo to take you from returning a simple browse file path to populating the ListView with files, file details, and image icons.

ListView Extended Style demo code - revised September 1998
Each article below builds on the previous one, so only the code related to that article is presented for simplicity. The routines can be applied to the ListView demo code above, or integrated into an existing ListView project.

SendMessage: Auto-size ListView Column Width
Using SendMessage to cause the ListView to maximize its column display. Feb 12.2000

Pure VB: Create a Ledger-Style Listview Report Background
Applying row background colour without subclassing.  Feb 5.2002  Corrected bug Feb 21.2002

Pure VB: Create a Ledger-Style Listview Report Background with Custom Height
Applying row background colour without subclassing, adding the ability to specifying the number of rows in the 'ledger'.  Feb 20.2002 Corrected bug Feb 21.2002

SendMessage: Add a Background Image to a ListView
Add an image or coloured background to a ListView! June 19.1998

SendMessage: Perform Hit Testing in ListViews
Using SendMessage and LVM_SUBITEMHITTEST to retrieve the HitTest info from the ListView control. Mar 01.2000

SendMessage: Determine a ListView's Visible Item Count
One-line routine that returns the number of items totally visible in the control. Aug 27.1999

Pure VB: Highlight a Listview Report Column
Using the picture box technique, demonstrates highlighting a column in report view. Feb 20.2002 Corrected bug Feb 21.2002

WM_NOTIFY: Track Highlighted ListView Column Width Changes via Subclassing
Using the picture box technique, demonstrates highlighting a column in report view while tracking and maintaining its width. Feb 20.2002

SendMessage: Automatically Track & Select ListView Items 
API code to track mouse movement, highlighting the item under the cursor, and automatically selecting it with delay.

SendMessage: Add ListView Check Boxes
API code to add a checkbox to the left of the report-view icon, and the code to retrieve the checked items and list item text.
Now contains the correct declaration for the LV_ITEM data type.

SendMessage: Add Images to a ListView Header 
The ListView API method to programmatically set, clear and toggle a ListView column header image, and to enable hot tracking across the column header. 

CreateFontIndirect: Change ListView Header Text Style 
Use the ListView APIs to change the header text style.

SendMessage: Determine Selected ListView ListItems
LVM_GETSELECTEDCOUNT and LVM_GETNEXTITEM to the rescue!
 Sept 16.2002

SendMessage: Clicking ListView White Space to De-select Items
Using SendMessage and LVM_SUBITEMHITTEST, code to determine when the user clicks off a ListItem, and how to deselect the item.
 Sept 16.2002

SendMessage: Determine Positions of Re-Ordered ListView Columns
API method to determine how the user has rearranged the columns when the drag & drop ColumnHeader option is enabled.

SendMessage: Display ListView Grid Lines 
API code to segment the ListView data with gridlines.

SendMessage: ListView Select / Deselect All May 5.1999
API call to select or deselect all ListItems without using a loop.

SendMessage: Reorder ListView Columns Programmatically
Use the API to reorder the report view columns via code. March 8.1999

SendMessage: Reposition ListView Columns 
API code to enable drag & drop of the ListView main and SubItem report-view columns to facilitate user-selected layout.

SendMessage: Enable ListView FullRowSelect
API code to cause a selected ListView item to select the entire row.

SendMessage: Set ListView Flat Header Style
The API method to enable/remove a flat appearance to a ListView header.

SendMessage: Indent ListView ListItems
Using the LV_ITEM Indent member to adjust a ListView item's indent. Oct 29.1999

SendMessage: ListView Subitem Icons 
API code to display the associated icon in each column of the populated ListView.

SendMessage: Toggle ListView Check Box State
Finally, the ListView API method to programmatically set or clear a ListView item's checkbox.

SendMessage: HTML-Like Tracking Effects in a ListView 
Two API code methods to highlight & underline the current item without selection.

SendMessage: Simulate 'TopIndex' in ListViews
Replicate a list box TopIndex property in a ListView control. Jan 25.2004

SendMessage: Controlling a ListView Sort Using Callbacks 
Use the AddressOf operator to add extended sorting functionality to ListView columns. Sept 5.1997

WM_VSCROLL: Subclassing Listview Scrollbar Messages
Demonstrates detecting scrollbar action within a listview, and scrolling a second control, modifying the scroll message, or discarding the message Aug 29.2000

WM_NOTIFY: Detect Sizing Notifications from a ListView ColumnHeader
Detect column resizing, header repositioning, clicks and double clicks on the ListView header. Aug 22.1999

SendMessage: Using ListView API Check Boxes 
A set of ListView API methods to programmatically set and clear a single ListView item's checkbox, set and clear all checkboxes, invert the state of checked/unchecked boxes, launch a selected item, and launch a checked item.

Pure VB: Link a TreeView and Listview Together via their Tag Properties
How to use the Tag property to allow a TreeView selection to highlight a corresponding ListView item
. June 21.1998



ProgressBar
vb6
vb5
vb4-32
SetParent: Add a VB ProgressBar to a VB StatusBar
Use SetParent to merge a VB progress bar into a VB status bar.  Feb 7.2002

SendMessage: Change the Colour of a VB ProgressBar
A simple SendMessage call is all that's required.
Oct 20.2001

Pure VB: Customizable PhotoShop-Style ProgressBar
Simulate a ProgressBar by creating a fully-configurable flood panel using without APIs.

Pure VB: Customizable PhotoShop-Style ProgressBar in a MDI App
Use the progress panel from Creating a Custom PhotoShop-Style Flood Panel to create a progress bar on an MDI parent window flood, exposed through common routines.

CreateWindowEx: Creating a Common Control ProgressBar- Overview
A discussion of the messages used by comctl32.dll in creating the ProgressBar Common Control.

Creating the Common Control Flood Panel via the API
Use the Win32 API to create a horizontal or vertical Windows-style progress bar. Revised code to implement the Common Control Initialization module detailed above.

SetParent: Display Modal Form Activity in a Parent Form's VB ProgressBar
How to update a VB progress bar sited on a parent form from a modal child form. July 29.1999

SetParent: Display Modal Form Activity on a Parent Form's 'PhotoShop-style' ProgressBar
How to update a picture box sited on a parent form (acting like a progress bar) from a modal child form. July 29.1999



Slider
vb6
vb5
WM_CTLCOLORSTATIC: Change the BackColor of a Slider
Subclassing to change the background colour of a VB slider control. Includes code to enable/disable the slider's ToolTips. Apr 7.2004


Status Bar
vb6
vb5
vb4-32
SetParent: Add a VB Toolbar to a VB StatusBar
SetParent and a couple of tweaks adds a VB toolbar into a VB status bar.   Jan 20.2002

CreateStatusWindow: The Common Control Status Bar via API- An Overview
A discussion of the messages used by comctl32.dll in creating a Status Bar Common Control.

CreateStatusWindow: The Common Control Status Bar via API
Use the Win32 API to create a status bar without an OCX.



Toolbar
vb6
vb5
vb4-32
SetParent: Add a VB Toolbar to a VB StatusBar
SetParent and a couple of tweaks adds a VB toolbar into a VB status bar.   Jan 20.2002

SetParent: Add a VB Toolbar to a MDI Form's StatusBar
Slight modifications are all that is required to add a toolbar to a MDI form's status bar. Mar 28.2004

FindWindowEx: Change a VB Toolbar to a Rebar-Style Toolbar
A quick 10 lines of code to change a standard VB toolbar control into an IE-style Rebar toolbar (aka 'coolbar').

FindWindowEx: Fix the IE5/MsComCtrl 5 Toolbar Problem
Workaround to the IE5/VB5 Common Control Toolbar problem where caption changing on a flat style toolbar will cause all captions to disappear. Aug 22.1999



ToolTips
vb6
vb5
vb4-32
CreateWindowEx: 21st Century ToolTips for VB - The Basics
Single or multi-line tooltips for VB, complete with tip titles and custom colours. Feb 13.2006


TreeView
vb6
vb5
vb4-32
SetWindowLong: Add TreeView Check Boxes via API July 29.1998
Add checkboxes to a TreeView and set and retrieve their state via code.

SetWindowLong: Apply TreeView Special Effectsvia API
Set TreeView back and text colours, bold an item, or set full row select. April 17.1998

Pure VB: Duplicating the Contents of a TreeView
A non-API method to create a duplicate TreeView. June 19.1998

SendMessage: Toggling TreeView Check Box Visibility
How to display or hide the TreeView checkboxes using the API. Dec 13.1998

Pure VB: Link a TreeView and Listview Together via their Tag Properties
How to use the Tag property to allow a TreeView selection to highlight a corresponding ListView item
. June 21.1998



 

 
 

PayPal Link
Make payments with PayPal - it's fast, free and secure!

 
 
 
 

Copyright ©1996-2011 VBnet and Randy Birch. All Rights Reserved.
Terms of Use  |  Your Privacy

 

Hit Counter