🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: For those who have struggled with callback

#7942
From: Angus
Date: Thu, 09 Dec 2004 07:12
65 lines
3132 bytes
Cheers Brent. :-)

"Brent" <nospam@nospam.com> wrote in message
news:41b7d761@newsgroups.borland.com...
> Great that you worked it out.  Here's a link to an article that discusses
> callback functions with C++, API and VCL events.
>
>
http://bcbjournal.org/articles/vol4/0007/Understanding_function_pointers.htm
>
>
> "Angus" <aguspickton@yahoo.com> wrote in message
> news:41b7d5c0@newsgroups.borland.com...
> > No matter how many times i read about callback functions, i could never
> > really grasp them. It often depends on the information is presented.
With
> > respect to callbacks, a little light flickered on, and here is an
> > explanation for anyone dense as hardwood like myself. - and if you don't
> > like it, oh well.
> >
> > Callback - the passing of your own function as a parameter into another
> > function. Consider the call.
> >
> > void __fastcall TForm1::Button1Click(TObject *Sender){
> >     std::auto_ptr<TComboBox>CB(new TComboBox(this));
> >     SomeFunction( MyFunc, CB);
> > }
> >
> > Now SomeFunction may be something you have written to retrieve a list of
> all
> > say all process names.. ie.
> >
> > BOOL WINAPI SomeFunction(PROCENUMPROC myfunc, LPARAM lParam){
> >    // ...some code..e.g getting a the next process in a snapshot list.
> now
> > call your own function MyFunc.e.g.
> >
> >   while(MyFunc(processname, lParam) && ProcessesRemain){
> >          //pass in a var from this func, AND a var from your calling vcl
> > program
> >         if(dada)
> >            ProcessesRemain = false;
> >   }
> > }
> >
> > ...and MyFunc...
> > BOOL CALLBACK MyFunc(char*  processname, LPARAM lParam){
> >    TComboBox* cb = (TComboBox*)lParam; //do a cast
> >     cb->Items->Add(AnsiString(processname));
> >     return true;
> > }
> >
> > In essence then, MyFunc is passed into SomeAPICallbackFunction. In this
> > example, each process is iterated using snapshot.
> > With each process found, a call to MyFunc is made, passing in the name
of
> > the process.. and in this instance a link to your calling program, a
combo
> > box.
> >
> > rgds Angus.
> >
> >
>
>
Technical Details
Message-ID: <41b7fad9$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!newsfeed.icl.net!newsfeed.wirehub.nl!194.72.7.126.MISMATCH!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <41b7d5c0@newsgroups.borland.com> <41b7d761@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,8db932b21c7928ca
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "Angus" <anguspickton@yahoo.com>
From: "Angus" <aguspickton@yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <41b7d5c0@newsgroups.borland.com> <41b7d761@newsgroups.borland.com>
Subject: Re: For those who have struggled with callback
Date: Thu, 9 Dec 2004 20:12:34 +1300
Lines: 67
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 219.88.83.204
Message-ID: <41b7fad9$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1102576345 219.88.83.204 (8 Dec 2004 23:12:25 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!newsfeed.icl.net!newsfeed.wirehub.nl!194.72.7.126.MISMATCH!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail