Click to See Complete Forum and Search --> : static functions and statusbars


Andrew Truckle
April 18th, 1999, 09:52 AM
I have no choice but to use a static member function for a particular peice of code. But it requires being able to set the text of a pane in my statusbar control and ofcourse, it doesn't work since the status bar is not static and I can't use "this".

In short then, how can I set the text via this static member function?

Art
April 19th, 1999, 06:24 AM
Hi...
You are right, you can't set a string while your status bar is not a window.
To avoid this problem, it is better to have a static char array, then use not static, something like SetString, function, when your status bar is created.

AAvetyan

Andrew Truckle
April 19th, 1999, 06:30 AM
Hi

I'm not too sure how to implement what you are saying. I've ended up making a global function which accesses a pointer to the dialog. This allows me access to the dialog status bar. A global function is also permissable as opposed to a static member function as a parameter passed to this other function which requires it. (make sense?!!!)

Dave Lorde
April 19th, 1999, 07:14 AM
The alternative way for static member functions to access an instance of the class, is to pass an instance into them as an argument when they're called...

class Foo {
public:
static void staticMFunc(Foo& aFooInst) { aFooInst.otherFunc(); }
void otherFunc() {}
};

void Bar()
{
Foo aFoo;
Foo::staticMFunc(aFoo);
}

Dave