[lazarus] Problem found
T Jan Schmidt
c9517606 at studentmailbox.newcastle.edu.au
Wed Jun 30 00:43:24 EDT 1999
In C++, I got around the problem of having no self (this) pointer by
making a global function as the callback, and having a self pointer as
part of the widget data (as in my previous email). I was looking for a
quick and dirty fix, so I used public methods on the class(object) and
simply typecast the widget data "self" pointer to the type I wanted, then
called the public method on that object.
A better solution (in C++) would have been something like:
class X {
friend void callback(...);
private:
void Handler();
};
void callback(...)
{
X *obj = ( X* (gtk_object_get_data(GTK_OBJECT(Widget),"self")));
obj)->Handler();
};
This relies on the "friend" C++ construct. I don't know if there is an
equivalent for Delphi - a modifier that says a global function is allowed
to call private member functions on the object. If there isn't, I don't
see a solution that doesn't involve making the object methods public.
AAnyone?
Jan.
More information about the Lazarus
mailing list