Article View: borland.public.cppbuilder.nativeapi
Article #8105Re: Help needed in Type Casting
From: FireHead
Date: Mon, 22 Nov 2004 22:47
Date: Mon, 22 Nov 2004 22:47
83 lines
3921 bytes
3921 bytes
Ed Mulroy [TeamB] wrote: > A structure definition is a type. You can then declare or > allocate one or more instances of a type. While for > efficiency only one set of physical instructions is > generated for a member function of a structure, the manner > in which the function is called includes specifying which > instance of the type those instructions are to work with. > > You specified a member function of a structure to Windows > as a callback function. Windows is not party to the > internal configuration of your program and has no > facilities to call a non static member function in the > context of whatever instance of that structure you > intended to be used. > > Only static member functions and normal functions that > are not members of a class or structure can be specified > as callback functions. > > . Ed > > >>FireHead wrote: >> >>... >>As you can see that I have function called LRESULT >>CALLBACK Events(....) >>which globally located. >> >>I have function called InitInstance which is part of >>Main_Window structure. >> >>Where I declare WNDCLASSEX wnd >>and then I declare the expression >>as << >> wnd.lpfnWndProc = & sig.Events; >> >>>>I get a error type casting in >> >>the following: >> >>Cannot convert >>'long (_stdcall *(_closure)(HWND__*,unsigned >> int,UINT,long))(HWND__* hwnd,unsigned int,UINT,long)' >>to >>'long (_stdcall *)(HWND__* hwnd,unsigned int,UINT,long)' >>in function >>struct MainWindow::InitInstance(const char*) >> >>Can someone tell me how do I fix this problem. > > Hello Ed: I have got to program because by declaring << struct Signal_Window >> as a global object and I created an function such WndProc in this struct. I was then able initialize the global object in the WinMain and I used the WinMain global object(s) address to access all the members and It worked. But my nearly seems remain the same. Why and should error should disappear when I declare a WndProc function as a static function. I just wanted get an understanding what does this operator <<static>> really does. And yes I did send a copy of this thread in a another forum because I not exactlty where to put. I only have Borland C++ 5.5 Compiler only. Your Comment: > You specified a member function of a structure to Windows > as a callback function. Windows is not party to the > internal configuration of your program and has no > facilities to call a non static member function in the > context of whatever instance of that structure you > intended to be used. If you have got Borland C++ 4.02 or greater and Look for windows examples; it exactly contradicts you statement.
Technical Details
Message-ID:
<41a26c56@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news.zanker.org!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<41a13964@newsgroups.borland.com> <41a17387$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,874f410c864356cd X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Tue, 23 Nov 2004 09:47:31 +1100 From: FireHead <satishA82@linuxmail.org> User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Help needed in Type Casting References: <41a13964@newsgroups.borland.com> <41a17387$1@newsgroups.borland.com> In-Reply-To: <41a17387$1@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 202.78.39.110 Message-ID: <41a26c56@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1101163606 202.78.39.110 (22 Nov 2004 14:46:46 -0700) Lines: 83 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news.zanker.org!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail