
Introduction
Drop-in MFC class to display temperature
Background
I had the need to display temperature readings from sensors.
After taking apart a couple of very nice controls written by
Davide Calabro I decided to try and show off.
Environment
This project was built and tested on Windows XP using Visual Studio 2003 SP1
Using the code
- Add GDI+ support to your application: Starting with GDI+
- Add TempCtrl.h and TempCtrl.cpp to your project.
- Include TempCtrl.h in your main window/form view class.
- Create a member variable of type
CTempCtrl.
- In the window initialization, subclass the thermometer:
BOOL int CMainDlg::OnInitDialog()
{
m_TempCtrl.SubclassDlgItem(IDC_TEMP, this);
Acknowledgments
Very special thanks to Davide Calabro for his knob and cylinder progress controls:
TODO
The control's size currently has to be within a certain range
to be look right. In the future I will dynamically set line
widths, font sizes, etc from the control size.
History
Jan 31st 2007 - Original Article.