Board index » cppbuilder » design time object adress NULL in run time

design time object adress NULL in run time

I have a TStoredProcedure( procB )object in design time. I use oracle 8.05.
during design time it work properly, I can observe parameters etc. but in
run time, the address of procB turns to NULL. as if no memory allocated to
this object. but it is a design time object.

is any body encountered this problem ?

 

Re:design time object adress NULL in run time


Quote
Mahmut Esitmez wrote:

> I have a TStoredProcedure( procB )object in design time. I use oracle 8.05.
> during design time it work properly, I can observe parameters etc. but in
> run time, the address of procB turns to NULL. as if no memory allocated to
> this object. but it is a design time object.

Try stepping into the form loading code. It is very insightful.

Have you ever consider how member pointers of a form get assigned? Think about it.
You place a label on a form. BCB adds a TLabel* variable to your form class called
Label1. When you run the program, Label1 magically points to the TLabel instance. How
does this work? There is no code in your form class to assign or create Label1. So
how does it get assigned?

The answer is that BCB puts these member pointers in the published section of your
form. By doing so, the member pointer is available to the base classes of your form
via RTTI. When the form is loaded, the reader classes instantiate the label object,
stream in its properties, and then assign the value of the Label1 pointer for you.

There are two things that can mess this system up. If you move Label1 accidentally
out of the published section and into the private or public section of your class. If
you do this, the base classes that read in the DFM can't find your label pointer. The
label is still created and appears on the form, but your member pointer does not get
assigned so it ends up containing either NULL or garbage.

The second item that can mess this up is if you rename the member variable from the H
file (say from Label1 to m_Label). The base classes find your pointer by name. If you
change its name from the H file, the name in the class won't match the name from the
DFM file. Once again, the label still gets created, but the assignment of your member
pointer does not occur.

Harold Howe [TeamB]
http://www.bcbdev.com

Other Threads