Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!csn!tramp.Colorado.EDU!rink From: rink@tramp.colorado.edu (Jeff) Newsgroups: comp.windows.x Subject: C++ and X: Member-Functions as Callbacks Message-ID: <1991Mar9.123358.14352@csn.org> Date: 9 Mar 91 12:33:58 GMT Sender: news@csn.org (news) Organization: University of Colorado, Boulder Lines: 58 Originator: rink@tramp.Colorado.EDU Nntp-Posting-Host: tramp.colorado.edu Howdy. Help requested from C++ and X gurus: I am trying to set up a callback for an X widget. I would LIKE to have the callback be a member-function of a C++ class. An example: struct blah { void foo(); } .... blah instance; XtAddCallback( ---- , ---- , instance.foo, ---- ); The problem(s): When I try it (as in the example), foo() is not called with the proper, hidden, THIS* argument. THIS, in fact, points to a mess. I suspected that X is packing the normal callback arguments where they shouldn't be (w, client_data, and call_data), so I tried explicitly specifying the arguments: struct blah { void foo(Widget, caddr_t, caddr_t); } But it still doesn't work. THIS still points somewhere else. Any ideas? I'm sorry if this isn't more clear. I'm rather new to both X and C++. Jeff Rink (rink@tramp.colorado.EDU)