πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Callback function as method class

#9388
From: Arnie Mauer
Date: Fri, 09 Jul 2004 14:13
65 lines
2693 bytes
MakeObjectInstance() is in forms.hpp in BCB 5.  It was probably just left
out of the help.

- Arnie

"Sam" <skneife3@wanadoo.fr> wrote in message
news:40ee67a8@newsgroups.borland.com...
> Remy, thank you for your sample, but I use BCB 5 and it seems that
> MakeObjectInstance is for the version later, because in the help there is
no
> link.
>
> Samir
> "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: <40eea839$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40ee3b69@newsgroups.borland.com> <40ee651d$1@newsgroups.borland.com> <40ee67a8@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,68c63a4b5ad1dd83
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII
From: "Arnie Mauer" <someone@microsoft.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <40ee3b69@newsgroups.borland.com> <40ee651d$1@newsgroups.borland.com> <40ee67a8@newsgroups.borland.com>
Subject: Re: Callback function as method class
Date: Fri, 9 Jul 2004 10:13:38 -0400
Lines: 67
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: 12.29.236.34
Message-ID: <40eea839$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1089382457 12.29.236.34 (9 Jul 2004 07:14:17 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail