Decimal Point Aligned
Properties
Site Map Feedback

Download:

Up Properties Select Sort

CListBox

This is a direct replacement for a CListBox which is being used to display property values.
The ListBox holds whatever strings you give it but renders them in a formatted way:
Name: Value
The first colon ':' in the string terminates the Name.
All Property Names are displayed, left-justified.
All columns are automatically sized to ensure all data is displayed.
If Value is not numeric, it is displayed left-justified.
If Value is numeric, it is displayed with decimal point alignment.
Internally, CListBox uses two further columns for the decimal-alignment: the integral part being right-justified, and the fractional part being left-justified.

The control also has a concept of Sections.
Sections of properties are separated with a blank line (See how the "Short Section" is separated in the following code example.
The animation shows resizing CPropertyViewer (Left window) and a standard CListBox (Right window).

You can clearly see the decimal alignment and Sections keeping themselves visible.
If SectionalWidths is set (which it is by default) and the window is too narrow to display the whole of the long section,
the Short Section will try to keep the values visible by moving them closer to the name while there is space to do so.
The closeness of the Values to the Names depends on the available Window Width.
This is similar to browser behaviour if each Section were a Table with Width set to 100%.

If AutoCopy is set, and a CEdit control has the focus, clicking on the ListBox will transfer Value to the CEdit.
Otherwise you can set up a Right-Click context menu with Copy and use the Copy functions to copy the Value or whole string to the Clipboard.

Usage:
Put a ListBox in your Dialog (here it is assumed that it's called IDC_LIST1)
in the Properties for the ListBox set:
Add the PropertyViewer.h and PropertyViewer.cpp Files to your Project.
In your Dialog Header File include this File:
#include "PropertyViewer.h"
and add a Member to your Dialog Class:
  CPropertyViewer PropertyViewer;
In the OnInitDialog() put the following lines:
  PropertyViewer.SubclassDlgItem(IDC_LIST1,this);
  AddString("Very Long Title Text:");
  AddString("");
  AddString("Very Long Comment Text.");
  AddString("Text Value: Description.");
  AddString("Integer Value a: 0");
  AddString("Integer Value a: -0");
  AddString("Integer Value b: -123");
  AddString("Decimal Value a: 3000.0");
  AddString("Decimal Value b: 1.234");
  AddString("Decimal Value c: 2.2");
  AddString("Decimal Value c: -0.00");
  AddString("");
  AddString("Tool Directions");
  AddString("Direction: CCW");
  AddString("Inside/Outside: Inside");
  AddString("Side: Left");
  AddString("");
  AddString("Short Section");
  AddString("Text: Description.");
  AddString("a: 123.4");
  AddString("b: 12.34");
  AddString("c: 1.234");
  AddString("d: 1234");

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.