Application Security Testing: An Integral Part of DevOps
AutoFill OCX Description
Recently while programming a dialog with a lot of input fields I discovered how big a pain it was to test the dialog because of the number of controls to fill in. I wrote this small OCX to fill the fields in for me. This allowed me to focus on the debugging instead of entering data.
The AutoFill OCX was written in VC 6.0
To integrate the AutoFill OCX into your code just go to "Project" menu selection. Select "Add to Project" and then "Components and Controls". Select the AutoFill from the "Registered ActiveX Controls" folder. Now just drag and drop the AutoFill from the component tool bar to your dialog. Then select the Class Wizard and add a member variable for the AutoFill OCX. Now you are ready to use the AutoFill OCX.
Using The AutoFill OCX
After a variable name has been assigned to the OCX all you need to do is call the OCX's functions using that variable. In the dialog you wish to test add the following lines to you initializing()function. Of course, you will want to use the ID Values for your dialog. Just call AddControl () once for each control you wish to have autofill. Then Tell the OCX what the name of the dialog is and the Data file which contains the data to insert.
m_pAutoFill.ClearControls (); m_pAutoFill.AddControl (IDC_NAME); m_pAutoFill.AddControl (IDC_ADDRESS1); m_pAutoFill.AddControl (IDC_ADDRESS2); m_pAutoFill.AddControl (IDC_CITY); m_pAutoFill.AddControl (IDC_STATE); m_pAutoFill.Section ("Dialog1"); m_pAutoFill.FileName (".\\Debug\\TestFill.dat");After the program compiles the last step is to create the data file that the OCX will read. The Data file has two types of data in Section names inclosed in  and the data and a comma between each field. The numbers below the section name is the next line to be read into the OCX. This field should be a number most likely 00001. This field should be at least 10 char. long. You should have the same number of fields as you added in the dialog code. You must add at least one blank line after all the data for that section. Sorry there is no error checking for correct format of the data file.
[Dialog1] 00001 ] Ron Benninghoff,91982 West My Town,,Phoenix,AZ Mickey Mouse ,102 Disney Land Dr,,DisneyLand,CA Donald Duck ,505 Disney land Dr,,DisneyLand,CANow you are ready to run the program. You will see the small autofill icon on the screen. Move the mouse to that icon and press the left button. This will fill the dialog fields with the Data in the data file. Each time you click on the autofill icon the dialog fields will be filled with the next line of data. When you reach the end of the data it will stop entering data for you. If you press the right mouse button over the autofill icon the data will reset itself back to the first line of the data.
AutoFill's OCX Methods
|Properties||Description of Properties|
|AddControl||Add a new Control to the list of controls to be filled in.|
|ClearControls||Remove all Controls from the list of controls.|
|FileName||Load the OCX with the name of the data file.|
|Section||Load the OCX With the name of File's section to read.|
|FillDialog||Tell the OCX to fill the dialog. (Same as Left mouse button on OCX)|
AutoFill's OCX Source Code
I am not going to include the source code here because if you are like me, I would prefer to download the code instead of cutting it from the article and pasting it into my code. The Source code has been documented so it should be easy to follow. The only files that have been changed from the default OCX code are the AutoFillCtrl.cpp & AutoFillCtrl.h file.
AutoFill's OCX Source Code Bugs
Expect Bugs! As I said at the start of the article this was a a quick and dirty OCX and it does what I need to do. If you find any problems please let me know and if time allows I will fix it.