OWLNext 7.0
Borland's Object Windows Library for the modern age
|
The TColumnHeader class creates a horizontal window that is used above columns of text or numbers, containing titles for each column.
The right panel of the Windows 95 Explorer, for example, uses this type of window for file name, size, and type. Column Header windows are generally used over a List Window window.
A header window contains parts called header items. The user can adjust the width of each item. Items can also behave like push buttons: clicking on the Size item in the Windows 95 Explorer, for example, sorts the files by size. Each item can have a string, a bit-mapped image, and a 32-bit application-defined value associated with it.
The native control for Windows 95 is the Header Window common control.
To create a Column Header Control, simply create a TColumnHeader object within the constructor of the parent object specifying the parent and the id of the control. For example,
When constructed within the constructor of the parent object, it is not necessary to invoke the Create method of the TColumnHeader object. The AutoCreate feature of ObjectWindows will ensure that the control is created once the parent object is created. However, if you are constructing the TColumnHeader object after its parent has been created, you will also need to invoke it's Create method.
Once the control has been created, you can add items using the Add or Insert methods of the TColumnHeader class.
The THdrItem class holds information about an item of a Column Header Control. To add/insert an item you must first construct a THdrItem instance. After initializing the THdrItem instance, you can invoke the Add or Insert method of the TColumnHeader object.
For example:
The Column Header Control sends notification messages to its parent window whenever the user manipulates the Column Header Control. For example, if the user clicks an item, the control sends a HDN_ITEMCLICK notification message. ObjectWindows provides several macros which can be used in the definition of a Message Response Table, allowing a member function to be invoked when particular notification messages are received by the parent. The following list shows the macros pertinent to the Column Header Control:
A Column Header Control is typically docked to the upper side of its parent's client area. The control provides an API which allows the control to specify a desired size and position within the boundary of a specified rectangle. The bool Layout(TRect& boundingRect, WINDOWPOS& winPos) method can be used to retrieve the appropriate size and position values in a WINDOWPOS structure. The overloaded bool Layout(uint swpFlags = 0) method provides an higher abstraction of this API: the desired size of the control is retrieved by specifying the client area of its parent as the bounding rectangle and the control is then repositioned accordingly. The swpFlags are used when the call SetWindowPos is used to reposition the control.