AutoFill OCX

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.

MFC Versions
The AutoFill OCX was written in VC 6.0

AutoFill OCX Integrating
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,CA


Now 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.

Download demo project - 59 KB

Download source - 53 KB

History



Comments

  • What about Comboboxes & Listboxes

    Posted by Legacy on 08/24/1999 12:00am

    Originally posted by: Victor Boctor

    Hi,

    Nice idea.....

    What about handling combo boxes whether they are just list or list edit? In addition the case of single selection list boxes should also be easy to handle.

    Thanks,
    Victor Boctor.

    Reply
  • nice testprogram

    Posted by Legacy on 06/30/1999 12:00am

    Originally posted by: Julius Ivanyi

    Hi
    I have compiled and run under VC++6.0 and did not get any problems. I think it is a very nice idea and implementation snd could have used it many times before, in the same situation, myself, too. I am sure I will use it as often as I will test a new GUI to be filled in with zillions of data.
    Thanks
    Julius

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • On-demand Event Event Date: September 10, 2014 Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild." This loop of continuous delivery and continuous feedback is how the best mobile …

  • On-demand Event Event Date: September 17, 2014 Another day, another end-of-support deadline. You've heard enough about the hazards of not migrating to Windows Server 2008 or 2012. What you may not know is that there's plenty in it for you and your business, like increased automation and performance, time-saving technical features, and a lower total cost of ownership. Check out this webcast and join Rich Holmes, Pomeroy's practice director of virtualization, as he discusses the future state of your servers, …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds