📄 cdigitst.html
字号:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Author" CONTENT="SoftechSoftware">
<TITLE>CDigitST documentation</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<FONT Face="Verdana,Arial" Size=2>
<CENTER>
<FONT SIZE=+4>CDigitST v1.0</FONT><BR>
Copyright (C) 1998 by SoftechSoftware<BR>
Thank you for use this SoftechSoftware! Thanks very much!
</CENTER>
<BR><BR>
<FONT SIZE=+2>Contact addresses</FONT><BR><BR>
SoftechSoftware E-Mail: <BR>
<A HREF="mailto:davide_calabro@yahoo.com">davide_calabro@yahoo.com</A>
<BR>
SoftechSoftware homepage: <BR>
<A HREF="http://members.tripod.com/~SoftechSoftware/index.html">http://members.tripod.com/~SoftechSoftware/index.html</A>
<BR>
CDigitST homepage: <BR>
<A HREF="http://members.tripod.com/~SoftechSoftware/cdigit.html">http://members.tripod.com/~SoftechSoftware/cdigit.html</A>
<BR><BR><BR>
<FONT SIZE=+2>Description</FONT>
<BR><BR>
CDigitST is a class derived from MFC CStatic class.<BR>
This class easly lets put digital counters inside your applications!
<BR><BR>
CDigitST features: <BR>
<UL>
<LI>Easy to use!
<LI>Create a new digital style just drawing a bitmap
<LI>Automatic resize feature
<LI>Written in Visual C++ v5.0
<LI>Full source code included!
<LI>It's free!
</UL>
<BR>
You are encouraged to use this class everywhere you want; there is no fee
required for CDigitST. Freely add modifications and/or fix bugs, but please,
send any of these to
<A HREF="mailto:davide_calabro@yahoo.com">SoftechSoftware</A>!
<BR><BR><BR>
<FONT SIZE=+2>How to integrate CDigitST in your application</FONT>
<BR><BR>
<PRE>
In your project include the following files:
<FONT COLOR="#990000">
DigitST.h
DigitST.cpp
</FONT>
You also need a bitmap containing the actual digits. This bitmap must have
the following format:
- Each digit must have the same width and height
- In the bitmap must be present 12 digits: 0..9 [blank] and [-]
[blank] will be used for zeroes to the left
[-] will be used as minus sign
For example include in your project Small_1.bmp and call it IDB_SMALL1.
With dialog editor create a static control called, for example, IDC_COUNTER
and create a member variable for it:
<FONT COLOR="#990000">
CDigitST m_dgtCounter;
</FONT>
Now attach the static control to CDigitST. In your OnInitDialog procedure:
<FONT COLOR="#990000">
// Call the base method
CDialog::OnInitDialog();
// Create the IDC_COUNTER digital counter
m_dgtCounter.SubclassDlgItem(IDC_COUNTER, this);
</FONT>
The control can display any number of digits you want (maximum is 10). Don't
worry about the control dimensions since it will be resized at runtime depending
on the precision (number of digits) you want.
The control can be expanded/shrinked from left-to-right (or viceversa) and from
top-to-bottom (or viceversa). See "CDigitST members" section for a detailed
explanation of all possible resize values.
Set resize direction to left-to-right and top-to-bottom:
<FONT COLOR="#990000">
// Set resize direction
m_dgtCounter.SetResize(CDigitST::ST_RIGHT | CDigitST::ST_BOTTOM);
</FONT>
Now assign the bitmap to the control and set its precision:
<FONT COLOR="#990000">
// Assign bitmap and precision
m_dgtCounter.SetStyle(IDB_SMALL1, 5); // The control will be automatically resized
</FONT>
CDigitST has a default starting value of 0 (zero) but any value (in the range of signed integers) can
be assigned to it:
<FONT COLOR="#990000">
// Assign a starting value
m_dgtCounter.SetValue(1000);
</FONT>
By default the zeroes at the left of the value will be not displayed.
This feature can be enabled/disabled at any time:
<FONT COLOR="#990000">
// Enable zero padding
m_dgtCounter.SetZeroPadding(TRUE);
</FONT>
Your static control is now a CDigitST!
Look inside the demo program to learn more about CDigitST. This is the best way!
Also give a look to the included bitmaps to learn how to implement your own
digital styles!
</PRE>
<BR><BR><BR>
<FONT SIZE=+2>CDigitST members</FONT>
<BR><BR>
<FONT COLOR="#990000" SIZE=+1>
BOOL SetStyle(UINT nBitmapId, int nPrecision);
</FONT>
<BR>
Set digital style and precision (number of digits)<BR>
The control will be automatically resized
<BR><BR>
Input values:
<UL>
<LI>nBitmapId<BR>
The resource bitmap to use as digits
<LI>nPrecision<BR>
Number of digits to display
</UL>
Return value:<BR>
Nonzero if successful; otherwise 0.
<BR><BR>
Example:<BR>
<FONT COLOR="#990000">
m_dgtCounter.SetStyle(IDB_SMALL1, 5);
</FONT>
<BR><BR>
<FONT COLOR="#990000" SIZE=+1>
void SetValue(int nValue, BOOL bRepaint = TRUE);
</FONT>
<BR>
Set current digital counter value
<BR><BR>
Input values:
<UL>
<LI>nValue<BR>
The new value
<LI>bRepaint<BR>
If TRUE the control is immediately redrawn
</UL>
Example:<BR>
<FONT COLOR="#990000">
m_dgtCounter.SetValue(1000);
</FONT>
<BR><BR>
<FONT COLOR="#990000" SIZE=+1>
int GetValue();
</FONT>
<BR>
Get current digital counter value
<BR><BR>
Example:<BR>
<FONT COLOR="#990000">
int nCurrent = m_dgtCounter.GetValue();
</FONT>
<BR><BR>
<FONT COLOR="#990000" SIZE=+1>
void SetPrecision(int nPrecision, BOOL bResize = TRUE);
</FONT>
<BR>
Set number of displayed digits (called precision)
<BR><BR>
Input values:
<UL>
<LI>nPrecision<BR>
Number of digits to display<BR>
If precision is too low the counter will be truncated at the left<BR>
Precision is limited between 1 and 10 (this limit can be easly modified)
<LI>bRepaint<BR>
If TRUE the control is immediately redrawn
</UL>
Example:<BR>
<FONT COLOR="#990000">
m_dgtCounter.SetPrecision(5);
</FONT>
<BR><BR>
<FONT COLOR="#990000" SIZE=+1>
int GetPrecision();
</FONT>
<BR>
Get number of displayed digits
<BR><BR>
Example:<BR>
<FONT COLOR="#990000">
int nPrecision = m_dgtCounter.GetPrecision();
</FONT>
<BR><BR>
<FONT COLOR="#990000" SIZE=+1>
void SetResize(DWORD dwResize, BOOL bResize = TRUE);
</FONT>
<BR>
Set control resize direction
<BR><BR>
Input values:
<UL>
<LI>dwResize<BR>
Resize direction. This value can be a bitwise-OR operation of the following values:
<UL>
<LI>ST_LEFT
<BR>Resize to left
<LI>ST_RIGHT
<BR>Resize to right
<LI>ST_TOP
<BR>Resize to top
<LI>ST_BOTTOM
<BR>Resize to bottom
</UL>
<LI>bResize<BR>
If TRUE the control is immediately resized
</UL>
Example:<BR>
<FONT COLOR="#990000">
m_dgtCounter.SetResize(CDigitST::ST_LEFT | CDigitST::ST_TOP);
</FONT>
<BR><BR>
<FONT COLOR="#990000" SIZE=+1>
DWORD GetResize();
</FONT>
<BR>
Get control resize direction
<BR><BR>
Example:<BR>
<FONT COLOR="#990000">
DWORD dwDirection = m_dgtCounter.GetResize();
</FONT>
<BR><BR>
<FONT COLOR="#990000" SIZE=+1>
void SetZeroPadding(BOOL bPad = FALSE, BOOL bRepaint = TRUE);
</FONT>
<BR>
Enable/Disable showing zeroes at the left of the counter (called ZeroPadding)
<BR><BR>
Input values:
<UL>
<LI>bPad<BR>
If TRUE the zeroes at the left are displayed
<LI>bRepaint<BR>
If TRUE the control is immediately redrawn
</UL>
Example:<BR>
<FONT COLOR="#990000">
m_dgtCounter.SetZeroPadding(TRUE);
</FONT>
<BR><BR>
<FONT COLOR="#990000" SIZE=+1>
BOOL GetZeroPadding();
</FONT>
<BR>
Get ZeroPadding state
<BR><BR>
Example:<BR>
<FONT COLOR="#990000">
BOOL bPadding = m_dgtCounter.GetZeroPadding();
</FONT>
<BR><BR>
<FONT COLOR="#990000" SIZE=+1>
void Inc(BOOL bRepaint = TRUE);
</FONT>
<BR>
Increment current digital counter value
<BR><BR>
Input values:
<UL>
<LI>bRepaint<BR>
If TRUE the control is immediately redrawn
</UL>
Example:<BR>
<FONT COLOR="#990000">
m_dgtCounter.Inc();
</FONT>
<BR><BR>
<FONT COLOR="#990000" SIZE=+1>
void Dec(BOOL bRepaint = TRUE);
</FONT>
<BR>
Decrement current digital counter value
<BR><BR>
Input values:
<UL>
<LI>bRepaint<BR>
If TRUE the control is immediately redrawn
</UL>
Example:<BR>
<FONT COLOR="#990000">
m_dgtCounter.Dec();
</FONT>
<BR><BR>
<FONT COLOR="#990000" SIZE=+1>
static const short GetVersionI()<BR>
static const char* GetVersionC()
</FONT>
<BR>
Return CDigitST version
<BR><BR>
Example:<BR>
<FONT COLOR="#990000">
int nVer = CDigitST::GetVersionI(); // Divide by 10 to get actual version<BR>
char szVer[20];<BR>
strcpy(szVer, CDigitST::GetVersionC());
</FONT>
<BR><BR><BR>
<FONT SIZE=+2>History</FONT>
<BR><BR>
<UL><LI>
CDigitST v1.0<BR>
First release
</UL>
<BR>
<FONT SIZE=+2>Things to do</FONT>
<BR><BR>
<UL>
<LI>Any suggestion?
</UL>
<P>
<HR>
<I>Copyright © 1998 by SoftechSoftware.</I> <BR>
<A HREF="mailto:davide_calabro@yahoo.com">davide_calabro@yahoo.com</A><BR>
</FONT>
</BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -