CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Andrew Truckle Guest

    [RESOLVED] static functions and statusbars

    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?


  2. #2
    Join Date
    May 1999
    Posts
    6

    Re: static functions and statusbars

    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

  3. #3
    Andrew Truckle Guest

    Re: static functions and statusbars

    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?!!!)


  4. #4
    Join Date
    Apr 1999
    Posts
    383

    Re: static functions and statusbars

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured