Building the Right Environment to Support AI, Machine Learning and Deep Learning
This article presents a CStatic derived class for displaying numbers or text like a LED Display. This control does not use bitmaps. Everything is drawn with lines and Bezier curves. First I made some classes to draw a character, which consists of segments that can be any closed shape, by only giving some points. The points can be connected by lines or by Bezier curves to make nice smoothened characters. The theory of fitting Bezier curves can be found in bezdist.pdf, created by Jim Fitzsimmons, in my demo project cabinet. The CDigistring resizes itself automatically, which can be experienced with the demo app, wherefore I used the resizing dialog code from Hans Bühler.
You can modify these if you like, then you can take them over to the source the same way as I did. The height of every design is the same only the width may be different, necessary for easy scaling.
BOOL ModifyDigiStyle(DWORD dwRemove, DWORD dwAdd);
With the MidifyDigiStyle function you can add or remove specific CDigistring styles. The styles, which can be combined by using the bitwise OR (|) operator, are:
CDigistring::DS_SMOOTH // Smooth kind of characters CDigistring::DS_STYLE14 // use always 14 segment display. CDigistring::DS_SZ_PROP // size proportional(default)
How to use (in a dialog):
- Add digistring.h, digistring.cpp, memdc.h, curvefit.h, curvefit.cpp and rgbcolor.h to your project environment.
- Add a static control to your dialog resource.
- Change its ID to something like IDC_LEDTEXT, open classwizard and assign a member variable, type control (CStatic) to it (m_LedText for example).
- Open your dialog class' header file.
Add #include "digistring.h".
Find the line CStatic m_LedText and replace the CStatic by CDigistring.
- In OnInitDialog() you can give it some text with SetText(),
change the colors with SetColor() or for the background SetBackColor() or you can
set the right style with ModifyDigistyle().
- Compile and run.
- Hans Bühler - For using his resizing software for the demo application;
- Keith Rule - For creating the memdc class for flickerfree drawing.
DownloadsDownload demo project - 163 Kb
Download source - 13 Kb