Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with my library .h

Status
Not open for further replies.

jrlago

Programmer
Mar 18, 2011
2
ES
Hello, my name is Jorge, I have a problem with Builder, in this case, version 5, the fact is that I use my small library with several functions ".h" in my program. So far so good.

The included in the project and define the unit1.cpp, the problem occurs when from the library try to edit the value of a component in the form1. Compiles and links fine but at run time the program ends with a "EAccessViolation"

Example:
If I do this from the Unit1.cpp goes well
Form1-> Label1-> Caption = "Hello World ";

But if I do this it from "milib.h" the program fails with "EAccessViolation"

Someone could tell me I'm doing wrong?

Thank you very much

Jorge
 
It sounds like the Application object has not created Form1 at the time you are trying to access it from the mlib module. You have to insure that Form1 has been created in memory by the application by using the following statement:

Application->CreateForm(__classid(TForm1), &Form1);

This is usually done in the program's WinMain function; however if it is being done AFTER your mlib is trying to access it, or not done at all, it will cause an EAccessViolation.
 
Hi, first of all thanks for your answer. I have winmain In

Application-> Initialize ();
Application-> CreateForm (__classid (TForm1), & Form1);
Application-> Run ();

That is what the Builder automatically generates, is no big deal about it.
Any idea more? thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top