★ wanayoo — archive 1999 http://codeguru.developer.com/controls/digistring.htmlNouvelle recherche | Portail wanayoo
EarthWeb
Developer.com Click Here!
Click Here!
Find:
 

EXPERT SEARCH
-----
Site
windows 2000
visual c++
java
visual basic
javascripts
recommend it
 
Contest
mfc codeguru
submission guidelines
 
Book
thinking in c++
stl programmer's guide
reviews
 
Interact
forums
newsgroups
guest book
jobs
jokes
open faq
what's new
 
Other
about
links
newsletters
privacy
tools
 

-----
Visual C++ by E-mail:

Get the weekly e-mail highlights on
Visual C++!
-----



EarthWeb Sites:
CROSSNODES
DATAMATION
DEVELOPER.COM
DICE
DISCUSSIONS
EARTHWEB.COM
EARTHWEB DIRECT
EARTHWEB EVENTS
ERP HUB
GAMELAN
GOCERTIFY
HTML GOODIES
INTRANET JOURNAL
ITKNOWLEDGE
IT NEWS
JARS
JAVASCRIPTS.COM
OPEN SOURCE IT
PERL JOURNAL
SYSOPT.COM
SUPPORTSOURCE
TECHCRAWLER
Y2KINFO

EarthWeb Worldwide

   

Static LED control


This article was contributed by Michel Wassink.

Sample Image

Overview

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.

To to design the characters I looked around for different styles. The most inspiration came out of my car. I used characters from the date/time/temperature display and from my RDS-radio. 14- And 7-segment displays in straight and smooth style are supported and one common character for displaying a decimal point or a colon. I changed the designs a lot to get aesthetically best results, but I didn't went crazy by changing all the points every time because I do some nifty mirrorring for most of the segments. For example i only specified 5 segments for the 14 segment display.

The Designs


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.

Changing styles


 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):

  1. Add digistring.h, digistring.cpp, memdc.h, curvefit.h, curvefit.cpp and rgbcolor.h to your project environment.
  2. Add a static control to your dialog resource.
  3. Change its ID to something like IDC_LEDTEXT, open classwizard and assign a member variable, type control (CStatic) to it (m_LedText for example).
  4. Open your dialog class' header file.
    Add #include "digistring.h".
    Find the line CStatic m_LedText and replace the CStatic by CDigistring.
  5. 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().
  6. Compile and run.

Acknowledgements

  • Hans Bühler - For using his resizing software for the demo application;
  • Keith Rule - For creating the memdc class for flickerfree drawing.

Downloads

Download demo project - 163 Kb
Download source - 13 Kb

History

Date Posted: February 17, 2000

Comments:

Add Comment

   

Give them a visit Click Here!

Click Here!

INSTANT EXPERTS!
Savvy IT Pros report on SupportSource. Take a look inside the largest vault of multi-vendor computing specs ever assembled. Click here for an In-depth Report,.

Learn about Free & Open Source software at the Bazaar Conference & Expo!,
December 14-16, 1999 in New York City! Click here for more information.

For tons of Windows technology resources, check out the Windows Programming directory.

Go to Fatbrain for the NEWEST and BEST technical books for IT professionals.

Get Linux Utilities for ONLY $34.95 at EarthWeb Direct.

Give them a visit Click Here!

Click Here!

Click Here!

Click Here!

Home About Us Search Subscribe Advertising Info Contact Us FAQs
Use of this site is subject to certain Terms & Conditions.
Earthweb's statement regarding our users' right to privacy.
Copyright ©1996-2000 EarthWeb Inc.. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of EarthWeb is prohibited.