Article View: borland.public.cppbuilder.nativeapi
Article #9410Re: Callback function as method class
From: Sam
Date: Sat, 10 Jul 2004 20:38
Date: Sat, 10 Jul 2004 20:38
55 lines
2389 bytes
2389 bytes
Remy, I hope that you can read my message !
Thank you very much, because one time more you have help me successfully !.
Thanks a lot.
Sam
"Remy Lebeau (TeamB)" <gambit47.no.spam@no.spam.yahoo.com> a οΏ½crit dans le
message de news:40ee651d$1@newsgroups.borland.com...
>
> "Sam" <skneife3@wanadoo.fr> wrote in message
> news:40ee3b69@newsgroups.borland.com...
>
> > The compiler refused. It seems that a class can't has
> > a callback as method, that is right ?
>
> Typically, to make a class method work as a callback, the method has to be
> declared as 'static'. However, in this particular case, you are using a
> window procedure. The VCL has a special function, MakeObjectInstance(),
> that can convert a non-static class method into a window procedure
callback.
> For example:
>
> class TMyClass
> {
> private:
> void* Ptr;
> public:
> TMyClass();
> ~TMyClass();
> };
>
> TMyClass::TMyClass()
> {
> Ptr = MakeObjectInstance(NewWindowProc);
> // you can use Ptr anywhere you need to assign a callback window
> procedure
> }
>
> TMyClass::~TMyClass()
> {
> FreeObjectInstance(Ptr);
> }
>
> void __fastcall TMyClass::NewWindowProc(TMessage &Message)
> {
> ...
> Message.Result = DefWindowProc(hSomeWnd, Message.Msg,
> Message.WParam, Message.LParam);
> }
>
>
> Gambit
>
>
>
Technical Details
Message-ID:
<40f053b9@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40ee3b69@newsgroups.borland.com> <40ee651d$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,68c63a4b5ad1dd83 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII Reply-To: "Sam" <skneife3@wanadoo.fr> From: "Sam" <skneife3@wanadoo.fr> Newsgroups: borland.public.cppbuilder.nativeapi References: <40ee3b69@newsgroups.borland.com> <40ee651d$1@newsgroups.borland.com> Subject: Re: Callback function as method class Date: Sat, 10 Jul 2004 22:38:31 +0200 Lines: 57 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: 193.253.34.244 Message-ID: <40f053b9@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1089491897 193.253.34.244 (10 Jul 2004 13:38:17 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail