Release date:
FoxTalk 2.0
April
From
Craig Boyd
Great tool
Author:
Doug Hennig
translation:
Sunny
Craig Boyd
(Creger
.
Boid
VFP
Developers create some great tools. This month,
Doug Hennig
analysis
Craig
Encryption function library and split strips and progress bar controls.
Craig Boyd
in
VFP
A new Microsoft, the most prominent expert in the group. He has a very interesting blog
(www.sweetpotatosoftware.com/spsblog),
,Yes
Sednax
Sponsor and one of the managers,
Sednax
Www.gotdotnet.com/codegallery/codegallery.aspx?id=0826d7a6-1DAB-4A71-8E70-F2170C3C1661)
Is a focus on expansion
VFP
Social area website, give
VFP
Developers have released many great programs. Let me not be surprising, not only the number of creative procedures and generously published, and creatively realize his ideas. This article tag me
FoxTalk
Writer
10
Anniversary, start a new series, look
Craig
Some tools have been created.
Encryption function library
In me
2006
January
FoxTalk 2.0
The article "Based on role security, the second part" I briefly discussed
Craig
of
Vfpencryption.fll
One direction
VFP
Developers provide library files for encryption and decryption functions. This month, we will be more close to it. You can
Www.sweetpotatosoftware.com/files/vfpencryption.zip
Download this library file. (Translator Note:
Vfpencryption.fll
There are two versions,
http://www.sweetpotatosoftware.com/files/vfpencryption.zip
Use
Visual Studio 2005
Compile, need
C 8.0
Runtime
MSVCR80.DLL
,
http://www.sweetpotatosoftware.com/files/vfpencryption71.zip
Use
Visual Studio 2003
Compile, need
C 7.1
Runtime
MSVCR71.DLL
,
VFP9
Have
MSVCR71.DLL
. )
Vfpencryption.fll
It is very easy to use:
Set library to vfpencryption.fll
And call one of its five functions.
• Encrypt (cstring, ckey [, ntype [, nmode]] -
Encrypt the specified string. I will detail each parameter later.
• Decrypt (cstring, ckey [, ntype [, nmode]] -
Decrypt the specified string.
• Encryptfile (csourceFileName, CTargetFileName, CKEY [, NTYPE [, NMODE]] -
Encrypt the specified file, the result of creating the target file is the function return value. (Two file names must refer to the full path)
• Decryptfile (csourceFileName, CTargetFileName, CKEY [, NTYPE [, NMODE]] -
Decrypt the specified file to the target file.
• Hash (cstring [, nhashtype]) -
Get the specified string
Hash
value.
Hash
It is a one-way encryption program that does not decrypt. It is often used for passwords, have stored in the initial password.
, Then when the user logs in, the input password
Hash
Value and storage
Hash
The value is compared.
Hash
The advantage of the value is different from other (encrypted) mechanisms, and there is no private key that can be leaked.
The following is a description of the parameters:
• CKEY-
It is a key to encryption and decryption. Obviously, when decryption, you must provide a key to encrypt strings or files. The key requires a specific length according to different encryption types.
• NTYPE-
Encrypted type.
Vfpencryption.fll
stand by
6
Encryption type.
0
Yes
AES128
,Claim
16
The key,
1
Yes
AES192,
Claim
twenty four
The key,
2
(default)
AES256
,Claim
32
The key,
4
Yes
Blowfish
,Claim
56
The key,
8
Yes
TEA
, Require language
16
The key, or
1024
Yes
RC4
This case can be arbitrarily.
• NMODE-
Encrypted mode, specified
0
(Default) Electronic source book book (
ECB
(Nats: One mode of password block operation, its main feature is to have a fixed ciphertext for each possible plain text content, and vice versa, in other words, the same plain text content Will be converted into the same cixed),
1
Password block connection
(CBC)
(Napp: a mode of password block operation, a series of binary code in the password block encrypts a unit or data block in the entire data block. The cryptographic block link uses a wide-known initial weight of the fixed length), Have
2
Credential feedback
(Cfb)
(Napp: a password block mode. With the password block link mode, it is a one-time encryption of a certain digital size password block, sometimes it needs to encrypt and transmit some plain text data values one by one, then Secondary feedback is an effective method.)
RC4
Encryption will ignore the value of the parameters.
• NhashType-
use
Hash
Type of functions, specified
1
Yes
SHA1
(also called
SHA160
),
2
Yes
SHA256
,
3
Yes
SHA384
,
4
(Default) is
SHA512
,
5
Yes
MD5
,
6
Yes
RIPEMD128
,or
Seduce
Yes
RIPEMD256
.
If you don't know how different encryption types and patterns, don't worry, I really don't have a clue on this aspect, this is what I like.
Vfpencryption.fll
The main reason.
TestVfpenCryption.prg
It is a demonstration that uses this function library.
Set library to vfpencryption.fll
* TEST Encrypting and Decrypting a string.
LCString = 'this is pretty cool stuff!'
LcKey = PADR ('this is a secret key phrase.', 32)
&& Padded to the Length Needed by The Default && Encryption Type
Lcencrypted = encrypt (lcstring, lckey)
Wait Window Lcencrypted
WAIT Window Decrypt (Lcencrypted, Lckey)
* TEST Encrypting and Decrypting a file.
Encryptfile (Fullpath ('TestVfpenCryption.prg'),;
Fullpath ('EncryptedFile.PRG'), LCKEY)
Modify file encryptedfile.prg
Decryptfile (Fullpath ('EncryptedFile.PRG'),
Fullpath ('DecryptedFile.PRG'), LCKEY)
Modify file decryptedfile.prg
* Test hashing a string.
Wait Window Hash (LCString)
Segmentation control
Split bars are very interesting controls: They don't have a visual interface itself, but you can change the size of other controls between two or more other controls to change the size of other controls. Split strip
Windows
There are many places in the application system,
Windows
The resource manager can use the split strip to adjust the size of the left and right panes. The split strip can be horizontal (left and right adjustment object) or vertical (up and down adjustment object), and two types that can be used in the same window (form).
in
1999
year
Seduce
month
FoxTalk
In my column, "
Splitting Up is Hard to DO
", One of me introduced
VFP
Segmentation bar,
Sfsplitter
And specific subclasses for levels (
Sfsplitterh
) And vertical (
Sfsplitterv
Segmentation. They are quite complex classes: they automatically add another class,
Sfsplitercover
, To their parent objects and use
Ole
Drag and drop the movement of the split bar. Add a split strip to the form to drag and drop the appropriate split classes to the form and set the same properties, indicating the name of the control of the control. Although this class is very difficult to create, I have successfully used the complexity of many projects and not only.
last summer,
Craig
In his blog released a division of a different implementation method, I must admit that I am doubtful. in
Splitter.vcx
There is only one separate
Splitter
Class, which only one property is used to set vertical, specify whether the split strip is vertical or horizontal.
-
And not a lot of code. It is assumed that each visual control is left and right (vertical segmentation) or up and down (horizontal segmentation), when the split bar is moved, the split strip is affected, (this is) a reasonable hypothesis, although you can place String "
Do n't_move_split
"Into
Tag
Any control will be ignored.
Let's take a look at how it works, and then drilled its code. From
Craig
Website download
Www.sweetpotatosoftware.com/files/splitter.zip
, Decompress to a directory, and execute
Do Form Splitter
. This is an example form, as shown
1
As shown, there are three edit boxes and two split bars, one level and the other. The upper and lower moving horizontal splitters and pay attention to the three editing frames are appropriately changed. The vertical segment of the left and right, the following two editing will inevitably be adjusted. Figure
1
Editing this form now, notice that in addition to correcting the size and positioning, only the attributes of the two segmentation controls are routinely changed.
Anchor
(Some of them respond to the size of the form) and
Vertical
(Indicates how to split the action).
Mousepointer
Attribute set "
9-size we
", But
Init
In the method, if
Vertical
Yes
.
Change it to "
7-Size NS
", Therefore, move the pointer into an appropriate shape when moving the mouse to the control, which makes the user know that it is a split strip control.
MouseDown
Event records the current in the mouse
X
or
Y
Coordinate (dependence
Vertical
Setup record
X
still is
Y
) To
MouseDownat
Custom properties.
Mouseup
with
MouseLeave
Set this property as
0
.
The actual work is
Mousemove
with
Move
In the case, I don't show this code here because I don't explain them in detail.
Mousemove
When the mouse is moved to the upper surface, make sure the left mouse button is pressed and
MouseDownat
Be greater than
0
If the mouse is pressed on another control and move to the top of the split strip, this will prevent anything. If the mouse moves (it is currently
X
or
Y
Coordinate
MouseDownat
Not the same), as long as it is not too close to the edge of the form, the program calculates how much it is moved, (whether it is too close to the edge) depends on the custom attribute
Minimumsize
,
Mousemove
transfer
Move
Method to do positive movement and reset
MouseDownat
Go to the new location.
Minimumsize
By default is
40
So the control can't be so small, using you can't see them or use them, but if necessary, you can set it a different value.
Move
Method is to do the despication of all controls and split strips itself in the influence of split bars.
DIRTY
)behavior. It is judgment
MouseDownat
Not
0
I only started, then lock the screen, then the movement of the object is all moved all over.
,
Does not show, calculate the distance of mouse movement, and the controls in its parent container, ignore any
Tag
Attribute is ""
Do n't_move_split
"The control, because it is a non-visible control. The code first saves the control.
Anchor
After the attribute value is set to
0
This is a necessary thing that does not completely display when this control is changed in the next form. If the split strip is vertical, the control is on the left or right side of the split strip, and if it is the right side of the division bar, the code adjusts the width of the control.
Left
Attributes. If the split strip is horizontal, the code is controlled to control its upper and the following is similar processing. Then restore the control
Anchor
Attributes. Saving the split strip after processing all the controls of the parent container
Anchor
Attribute, then move the split strip to its new location, restore it
Anchor
. Finally unlock the screen.
If you want to move split bars in programming, set
MouseDownat
For a non-zero value and call
Move
method. It can be used, for example, restore the split strip to the location of the last running form. For example, you can be in the form
Init
In the code like a bottom,
LNTOP
Value used as TOP of horizontal segmentation strips
Attributes.
With this.splitter
.MOUsedownat = .top
.Move (.left, lntop, .width, .height)
ENDWITH
It is like this, just as I said earlier, there is not much code in this class, it is more simple than the segmentation classes introduced several years ago, and it is easier to use. However, I am a serious person, I decided to create a subclass to change its processing.
Splitter
Assume that the controls on both sides are the same size. However, there are many times, while you must be bigger than the other, for example, there is a list box on the side that becomes very narrow, but the container and text box on the other side, it should be not.
in
Sfsplitter.vcx
of
Sfsplitter
It is the subclass of the split bar, which has two new properties:
NMINIMUMSIZE1
It contains the minimum size of the control on the left or above of the split strip, and
NMINIMUMSIZE2
It contains the minimum size of the controls on the right side of the split bar. If you default in them
0
When leaving them
Init
Set them as appropriate values. I then override
Mousemove
To use these properties is not
Minimumsize
.
Do form sfsplitter
See how my subclass is handled. Paying attention to the segmentation strips are not symmetrical in them, and the components on the side can be more big than the other, because I set it out.
NMINIMUMSIZE1
with
NMINIMUMSIZE2
For different values. This form is
Init
It also changed the initial position of the horizontal segmentation bar to show how to work.
Schedule control
The progress bar controls sometimes call the thermometer control, providing the user with feedback operation when the run is longer.
Visual FoxPro
Has been a long time
ActiveX
Control, Microsoft
Progressbar
Controls can be added to a form to provide feedback from this type. However, this control presents a descending trend, it has to be released and registered
Msconctl.ocx
. At the same time, because it is the old control, you will see it in other applications without a modern appearance and like a typical progress bar.
Only one week after the release of the segmentation control,
Craig
Published his progress control,
ProgressBarex.vcx
inner
Progressbar
. It is 100%
VFP
Code, so no
ActiveX
Published worried. You can also in the figure
2
I saw it, it looks like a standard
Windows XP
The progress bar is completely gradient and an optional one-scale tag.
Figure
2
download
Www.sweetpotatosoftware.com/files/progressbarex.zip
obtain
Craig
Screen control. Run (compressed package)
EXAMPLE
The form, enter a hundred value in the fine regulator, look at how it works. These three progress bars show the different ways of it can behave.
Let's take a look
Craig
How to achieve his progress bar. in
ProgressBarex.vcx
There are two categories:
PBBAR
It is a separate color block in progress bar, and
Progressbar
The progress bar itself.
Progressbar
There are a few properties that determine its appearance:
• Barcolor-
The color of the progress bar, when choice
1
Red,
2
(By default) is green, peace is blue.
• BARS-
The number of colors of the progress bar. The larger the value, the finer the color block.
• MIN-
The minimum value of the progress bar, the default is
0
.
• MAX-
The maximum value of the progress bar, the default is 100
.
• Percentage-
Currently completed hundreds of comparison.
• showpercentage-
When is
.
When the schedule is displayed in the progress bar.
• Solidbar-.t.
Show solid,
.
When (default) is displayed as a color block.
• Value-
The current value of the progress bar, you don't have to specify a hundred-fold value. For example, if your program is processing
1249
Set record, set
Max
for
1249
,
Value
Is the record number that is being processed.
Progressbar
of
Init
Methodology
BARS
Attribute specified quantity
PBBAR
Example, but did not set them
Visible
Attribute set to
.
Therefore, they were originally not shown. in case
Showpercentage
Yes
.
It also adds a label to the control.
Value
There is a property
ASSIGN
Method, used to calculate how many color blocks are displayed, and set those color block objects
Visible
Attribute
.
,in case
Showpercentage
Yes
.
Also update the title of the label.
Percentage
There is a property in the property
ACCESS
Method, according to
MIN
,
Max
,with
Value
The value calculation is completed.
Make this icon
Winows XP
The progress of the control is really incredible.
PBBAR
class. its
Init
Accept three parameters of color, width, and height of the color block (pass
Progressbar
Pass when it instantiates these objects). In order to display a color block,
Init
Instantiate a series
Line
Object, one
Line
A pixel of the height of the corresponding progress bar. These lines are painted with different colors, and the middle brunette is adjusted to the upper and lower tones and make an excessive effect. at the same time,
PBBAR
Set line
DrawMode
Attribute is ""
14-Merge Pen Not
"This allows the 100-fold label to display the correct color, even if it is partially or completely covered with the color block.
need to use
Craig
of
Progressbar
Class, simply drag it to the form, set the attribute as needed, and set in the processing cycle
Value
For a reasonable value. However, you might want to display progress in the same form from the start processing process, not using a separate form to display some progress. For example, I like to use some types of forms of forms, which will display progress bars in a panel in the status bar. I am using it.
Rick Strahl
of
WWSTATUSBAR
Controls rather than
ActiveX
Microsoft
STATUSBAR
Control, the same reason,
Craig
Scale
ActiveX
The control is better, see
Www.west-wind.com/presentstations/wwwstatusbar/wwstatusbar.asp
This is a link to describe this class and download source code.
Progressbar
Have a small problem, it is
Init
Do all the settings. The problem with this way is that it requires that attributes set up the values needed in the properties window. If you instantiate this class with programming,
Init
Events are excited before you have the opportunity to set properties. So, I created one
Progressbar
Subclasses,
SfProgressBar.vcx
middle
SfProgressBar
. I put it
Progressbar
of
Init
The code is copied to a name called
Setupprogressbar
New method, and in
Init
In addition to a comment, there is no thing when this class is instantiated. Because I am lazy and more appropriately avoiding manual calls
Setupprogressbar
So I added a call.
LSETUP
Custom properties, default is
.
, And in
Setupprogressbar
End setting it for
.
. Then I use the code below.
Value_assign
.
LParameters TunewVal
* Set up the program bar if it hasn't been done.
IF not this.lsetup
This.setupprogressbar ()
Endif Not this.lsetup
* If the value is 0, let's be invisible. Otherwise,
* Ensure we can be seen.
This.visible = TuneWVal <> 0
Dodefault (TunewVal)
This is guaranteed
Value
When the setting is obtained for the first time, the progress bar is completely set. I am sure when
Value
for
0
When the progress bar is invisible, the other values can be seen, so this code is handled.
I also built a
WWSTATUSBAR
(
http://www.west-wind.com/presentation/wwwwtatusbar/wwwwstatusbar.zip
Subclass,
Sfstatusbar.vcx
Call
Sfstatusbar
. This class
Init
Methodology
SfProgressBar
Form
Progressbar
Attribute, add one
Panel
Custom properties, display with the indicated progress bar in the panel, and used
Bindevent ()
,, When this property is changed, the new method
PutprogressBarinPanel
Stimulate. I also added called
Resize
Overcome
WWSTATUSBAR
One problem, when the form is displayed for the first time, due to its
Resize
Method, it does not completely display, so setting is bound to the form
Resize
event. If the form does not change the size, the status bar is properly not adjusted.
This.newObject ('progressbar', 'sfprogressbar ",;
'Sfprogressbar.vcx')
AddProperty (this.progressbar, 'Panel', 1)
Bindevent (this.progressbar, 'panel', ";
'PutprogressBarinpanel', 1)
Dodefault ()
THIS.RESize ()
Look in running
Sfstatusbar
,carried out
SfProgress
Form I click "
START Process
"Button, as shown
3
As shown, the progress bar is displayed in the second panel in the status bar.
Figure
3
This form is
Init
There is a code below, create a pair of panels and put the progress bar in the panel in the status bar.
2
in.
With this.Ostatus
.Addpanel ('Ready', 300 ,.t., 0)
.Addpanel ('', 200, .f., 1)
.Renderpanels ()
.Progress bar.panel = 2
ENDWITH
Button
Click
This progress bar is demonstrated with a pseudo-cycle.
* Have Status Panel 1 Indicate What We're Doing.Thisform.Ostatus.UpdatePanel (1, 'Processing ...')
* Perform a loop and show the princise.
For lni = 1 to 100
Thisform.Ostatus.progressBar.Value = LNI
Inkey (0.02, 'h')
Next LNI
* Reset The Progress Bar Back to 0 and Update Status
* Panel 1.
Thisform.Ostatus.progressBar.Value = 0
ThisForm.Ostatus.UpdatePanel (1, 'Ready')
to sum up
We saw this month.
Craig Boyd
Generous donation
VFP
Three tools in the community: a encryption function library and split strips and progress bar controls. Next month, the control we will see is based on
VFP
Calendar, scroll bar and task panel.
Author's source code download:
http://www.pinpub.com/media/publicationsArticle/604hennig_ft06d.zip