Click here to Skip to main content
15,919,879 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalslider scroll Pin
aguest11-Jun-03 12:44
aguest11-Jun-03 12:44 
Generallist of identifyers Pin
locoone11-Jun-03 12:29
locoone11-Jun-03 12:29 
GeneralRe: list of identifyers Pin
Rage11-Jun-03 23:00
professionalRage11-Jun-03 23:00 
GeneralRe: list of identifyers Pin
Anonymous12-Jun-03 1:36
Anonymous12-Jun-03 1:36 
GeneralHelp on exception handling..please.. Pin
Robert Buldoc11-Jun-03 12:19
Robert Buldoc11-Jun-03 12:19 
GeneralRe: Help on exception handling..please.. Pin
Joaquín M López Muñoz11-Jun-03 19:54
Joaquín M López Muñoz11-Jun-03 19:54 
GeneralRe: Help on exception handling..please.. Pin
Robert Buldoc11-Jun-03 20:35
Robert Buldoc11-Jun-03 20:35 
GeneralFormview + Scrollbar Pin
Atlence11-Jun-03 12:10
Atlence11-Jun-03 12:10 
GeneralRe: Formview + Scrollbar Pin
Roger Allen12-Jun-03 0:35
Roger Allen12-Jun-03 0:35 
GeneralRe: Formview + Scrollbar Pin
Atlence12-Jun-03 12:34
Atlence12-Jun-03 12:34 
GeneralTreeview Pin
Shotgun11-Jun-03 11:25
Shotgun11-Jun-03 11:25 
GeneralRe: Treeview Pin
Michael Dunn11-Jun-03 15:06
sitebuilderMichael Dunn11-Jun-03 15:06 
Generalfinding folders Pin
Steve L.11-Jun-03 10:30
Steve L.11-Jun-03 10:30 
GeneralRe: finding folders Pin
valikac11-Jun-03 10:48
valikac11-Jun-03 10:48 
GeneralRe: finding folders Pin
Steve L.11-Jun-03 11:17
Steve L.11-Jun-03 11:17 
GeneralRe: finding folders Pin
valikac11-Jun-03 11:25
valikac11-Jun-03 11:25 
GeneralRe: finding folders Pin
Anonymous11-Jun-03 21:21
Anonymous11-Jun-03 21:21 
Generalclass troubles! Pin
John Kohn11-Jun-03 10:20
sussJohn Kohn11-Jun-03 10:20 
GeneralRe: class troubles! Pin
Joaquín M López Muñoz11-Jun-03 10:26
Joaquín M López Muñoz11-Jun-03 10:26 
GeneralRe: class troubles! Pin
John Kohn11-Jun-03 11:19
sussJohn Kohn11-Jun-03 11:19 
GeneralRe: class troubles! Pin
Joaquín M López Muñoz11-Jun-03 11:50
Joaquín M López Muñoz11-Jun-03 11:50 
Well, Mike's FAQ explains it all, but I'll try to clear the issue up myself. Non-static members have, so to say, a hidden parameter pointing to the object the member function applies to (the this parameter, if you want to see it like that). After changing ListningForClients to static, the member function is no longer bound to any particular object via this, hence the error. This is what static means when applies to member functions: general functions not associated to particular instances of the class.
The way out of this problem is to use a callback paramter CreateThread provides just for this sort of things. In this parameter you can store a pointer to the relevant object and then use it accordingly. Pseudocode follows:
class CNetwork
{
  ...
  static DWORD WINAPI StaticListeningForClients(LPVOID Arg1)
  {
   CNetwork* object=(CNetwork*)(Arg1); // the object passed in CreateThread
   object->ListeningForClients();
  }
 
  void ListeningForClients() //non-static
  {
    // the real stuff here
  }

  ...
  CreateThread( NULL, 0, &ListeningForClients, this, 0, 0);
  // Here's the trick, we're passing this as the callback parameter
};
Hope you get the idea. Please read the FAQ for further clarification. Good luck.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
GeneralRe: class troubles! Pin
basementman12-Jun-03 6:37
basementman12-Jun-03 6:37 
GeneralHelp with .EXE file Pin
alexboza11-Jun-03 10:04
alexboza11-Jun-03 10:04 
GeneralRe: Help with .EXE file Pin
David Crow11-Jun-03 10:28
David Crow11-Jun-03 10:28 
GeneralRe: Help with .EXE file Pin
kochhar11-Jun-03 12:40
kochhar11-Jun-03 12:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.