🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #3706

Re: TimeSetEvent

#3706
From: Remy Lebeau (TeamB)
Date: Fri, 28 Apr 2006 18:55
24 lines
2269 bytes
"Bob Gonder" <notbg@notmindspring.invalid> wrote in message
news:32i4521k20p3ha1bq744jvbfteei2kr01q@4ax.com...

> Bottom line is callbacks must be static or else non-members.

There is a third option, though not very straight forward - use a proxy.
That is what the VCL does to allow non-static class methods to be used as
Win32 API window procedure callbacks.  Basically, for each desired method
for each class instance, you allocate a block of executable memory that
contains a stub function along with the class instance's 'this' pointer and
desired method pointer.  Then you can pass the memory block whereever a
non-member callback is expected.  When the API calls the callback, the stub
function is executed automatically, which then decodes the parameters from
the call stack and reformats the call stack to place the 'this' pointer onto
the stack, and then jumps into the class method.  As far as the class
method's inner code is concerned, it will act exactly as if it had been
called directly by the API without a proxy.  It is a very effective
technique, albeit not a trivial one to implement since you have to use
low-level assembly code for the stub function.  If you have the VCL source
code installed, you can look at the code for the MakeObjectInstance()
function for an example.

Gambit
Technical Details
Message-ID: <445265cc$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <ozchzhq02-9725F7.12284128042006@frylock.local> <32i4521k20p3ha1bq744jvbfteei2kr01q@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,7550567434949799
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <ozchzhq02-9725F7.12284128042006@frylock.local> <32i4521k20p3ha1bq744jvbfteei2kr01q@4ax.com>
Subject: Re: TimeSetEvent
Date: Fri, 28 Apr 2006 11:55:36 -0700
Lines: 26
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <445265cc$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1146250700 68.69.17.41 (28 Apr 2006 11:58:20 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail