Visit the Ultimate Toolbox main page for an overview and configuration guide to the Ultimate Toolbox library.
Source code and project files for this sample can be found in the samples\gui\PhysicalTest directory of the sample projects download.
Overview
The COXTimeEdit
, COXAngleEdit
, COXLengthEdit
, and COXTempEdit
classes are all derived from COXPhysicalEdit
which is derived from CEdit
.
Have a look at the Page Setup dialog boxes in Windows 95 and compare them to the margins setup property page in the Microsoft Office applications (or others). The fundamental difference is that in the Office applications, you can enter the values for margins as a physical value (numerical value and a physical unit) whereas in the standard dialog, you cannot supply a unit.
The COXTimeEdit
, COXAngelEdit
, COXLengthEdit
, and COXTempEdit
classes allow you to implement the same type of controls in your own applications: for time (duration), angle, length, and temperature. No need to define a fixed unit at desigdn time for your dialog boxes or property pages any more.
Features
- Adds physical units to numerical input in edit controls.
- Built-in functions for conversions between physical units.
- Functions for setting and retrieving physical values in desired units.
- No need for
SetWindowText()
and GetWindowText()
any more.
- Extended
COXPhysicalEdit
base class which can be easily derived to implement other physical properties (area, speed etc.).
Usage
You can attach a COXPhsicalEdit
derived control to an existing edit control by subclassing the latter.
As per usual, place a standard edit control on the dialog using the dialog editor. Invoke the Class Wizard and select the Member Variables page. Add a member variable for the ID of the edit control, selecting a CEdit
control as the type.
Next, open the header file for the dialog. Include the OXPhysicalEditEx.h
header. In the AFX_DATA
section for the dialog you will see the declaration for the edit control as a CEdit
. Change this to the control you wish to use ( OXPhysicalEditEx.h
contains the class declarations COXTimeEdit
, COXAngelEdit
, COXLengthEdit
, and COXTempEdit
.)
Don't forget to include the OXPhysicalEditEx.cpp
file in your project!
The sample demonstrates the use of four COXPhysicalEdit
derived classes, subclassing them in the dialog:
#include "OXPhysicalEditEx.h"
class CPhysicalTestDlg : public CDialog
{
public:
CPhysicalTestDlg(CWnd* pParent = NULL);
enum { IDD = IDD_PHYSICALTEST_DIALOG };
...
COXTempEdit m_wndTemp;
COXTimeEdit m_wndTime;
COXLengthEdit m_wndLength;
COXAngleEdit m_wndAngle;
...
The compiled HTML help documentation contains complete class references for COXPhysicalEdit
,COXTimeEdit
,COXAngleEdit
,COXLengthEdit
,and COXTempEdit
, as well as the extended CEdit
derived classes COXEdit
, COXNumericEdit
, COXCurrencyEdit
, COXMaskedEdit
, and the templated COXDropEdit
.
Initial CodeProject release August 2007.