Archived

This topic is now archived and is closed to further replies.

Object Required??

This topic is 5779 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have made my WinProc a member of one of my classes. Now when an event occurs I need to call a function do to stuff. But this always requires an object. It says: "Member spelers cannot be used without object". My WinProc(just the standard windows one) is implemented like this:
  
LRESULT CALLBACK CWindow::WinProc(...)
...
   Case 1001:
   {
      for (lTeller = 0; lTeller <= MAX_PLAYERS; lTeller++)
         Spelers[lTeller] = LegeSpeler;
      return(0);
   }break;

  
Spelers is an (private) variabele of the CWindow class. Why does this goed wrong? I already tried it with a function but that one failed too. Sand Hawk Member of the Stupid Coders. http://www.stupidcoders.cjb.net -Earth is 98% full. Please delete anybody you can.

Share this post


Link to post
Share on other sites
On that site they don''t place the WinProc inside the class, like I did. Can someone point me directly to an good tutorial/post that explains how I can fix this error?

Sand Hawk

Member of the Stupid Coders.
http://www.stupidcoders.cjb.net

-Earth is 98% full. Please delete anybody you can.

Share this post


Link to post
Share on other sites
The variables you used are nonstatic and your function is a static member function. To access the members, an instance of the class must be provided and accessed using the . or -> operators.

Edited by - SilentCoder on February 16, 2002 11:49:46 AM

Share this post


Link to post
Share on other sites
I admit that the examples on www.relisoft.com aren''t very clear or good, but the second tutorial (generic) does explain what you are looking for: getting to a certain window instance''s data in a static or global WindowProc.

In the tutorial each window has a controller, CreateWindow/SetWindowLong are used to couple the pointer to the controller with the window handle, the global WindowProc can get to the controller by using the windowhandle and GetWindowLong.

You probably don''t want to use the controller, but that doesn''t really matter: the point is that you can attach a pointer to anything to the window handle. In your case, you probably want a CWindow pointer, once you can reach the CWindow instance, you can easily call a non-static WindowProc for that instance, pWnd->WindowProc().

Share this post


Link to post
Share on other sites