Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
Member Area
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Become a Member
-Why sign up!
-Chat Online!
-Indexes NEW!!
-Build your resume
-Find a job
-Post a job
-Resume Search
-Link to us
Visit Embarcadero
Embarcadero Community
Algorithms Testing for classes, functions, component events Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
algorithms testing 01-Apr-04
CBuilder All Versions
User Rating
# Votes
Stubbs, David W
Reference URL:
			Testing Algorithms of classes, functions, component events

Create a function !

This is also a way to create a function or an event and hardcode 
it into the C++ Builder TForm::TForm1 class 

I wanted to show a message in response to pretty well any
event which could take place in any of the ready made
palette acquired C++ Builder visual or non-visual components.

Here I have used it in response to a Button1 Click event 

To simulate and test with this code example here are
the basics requirements.

Create a windows application - leave names etc to defaults
Use Form1 for this test
Add a button to the form - leave assignments as default.
Add other classes if you like

The steps for the Forms assignments :

1): Define the purpose for the function 

    : To show or send a message when some event or action
    : has taken place in an application.

Unit1.h assignments
2): Unit1.h function declaration is placed in either the 
     private or public part of the TForm1 class

2   __public
3       __fastcall void ShowAmessage();

Unit1.cpp assignments
3): Unit1.cpp definitions are placed following __fastcall TForm1 :
     or at the end of all the code in the .cpp file.

// This is the event or function that is called
5   void __fastcall TForm1::ShowAmessage()
6   {
7      ShowMessage("This is a message");
8   }

4): Where to place the function call code 
Finally place the function into the Button1 Click event
and click it. 

What the function does:
Any message you create will appear


The declarations worked also without the use of __fastcall
So, you can use fastcall or not - depending if it is just a function
or not. 

The .h declaration works in the private section as well but not 
in the published. I believe it would work it I had used this format
as an event for a component I had written. Something this little
bit of code can provide for very easily.

The code could also be used for testing purposes : such as
determining just when events are firing or what the results
are given a firing.  The code could also be extended to write
to a log file for a hardcopy reference of events and happenings.

This code may also work to track the actions of a class/object
functionality at runtime.

Add other development scenerios as you like. 

Happy programming !

David W. Stubbs

Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10


Share this page
Download from Google

Copyright © Mendozi Enterprises LLC