473,883 Members | 1,583 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Understanding callback

Hello,

I have seen the WndProc prototyped two ways,

LONG WINAPI WndProc ( .... );
and
LRESULT CALLBACK WndProc ( .... );

Are these functionally equivalent?
What are WINAPI and CALLBACK defined as?
Why are there two ways to go about this?

Thanks.
--

.--------------------.
| |
| Good Evening.... | .--.--.
| | .; .;|;. ;.
`-------------. ,---' .;_;' `;_;.
\| ; ;' `; ;
\ ;;'.--.___.--.`;;
;-( o )=3D( o )-;
( `--' | `--' )
\| . . |/
........... . .:::::. . .______
/ . '---` . '\
.' `. .' \
| ____,.- . | `.....' | _______ |
| ,-' \ /|\'' \.-- |
| / \.'\ /,'. \. - |
| /| ` `\ / \ |
| ,/ _ '/ '\ |
,-' ,-. |o '
/ '| | | | \
/ ,/| |o | \ `
| .' | |.' |. \ \
________/ .'____|________ _______________ _||__`. `__________
( \ ) / )
'-. '-. ( .-` .-`
'-. .-'--.__. .-.__.--`-. .-`
'-..' \--' : ~`:=3D,`- `..-`
\ .. \\ |`-'|`-, /
\\\\\\\) | |`-'/.'/
\)\)\\ `-' `-'
`

Nov 1 '08 #1
18 2748
kid joe <sp******@spamt rap.invalidwrit es:
I have seen the WndProc prototyped two ways,

LONG WINAPI WndProc ( .... );
and
LRESULT CALLBACK WndProc ( .... );

Are these functionally equivalent?
What are WINAPI and CALLBACK defined as?
Why are there two ways to go about this?
These are specific to Windows. You'll get much better information
if you post to comp.os.ms-windows.program mer.win32.

And please use a shorter signature.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Nov 1 '08 #2
kid joe wrote:
Hello,

I have seen the WndProc prototyped two ways,

LONG WINAPI WndProc ( .... );
and
LRESULT CALLBACK WndProc ( .... );

Are these functionally equivalent?
Under 32 bit windows they are equivalent.
Under 64 bit windows they are not since LRESULT
is a 64 bit type and LONG is a 32 bit type...

What are WINAPI and CALLBACK defined as?
WINAPI is _stdcall in 32 Bit windows
CALLBACK is also defined as _stdcall.

Under 64 bit windows _stdcall doesn't exist
so both definitions are equivalent too,
probably defined as nothing.
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Nov 1 '08 #3
On Sat, 01 Nov 2008 22:13:40 +0100, jacob navia wrote:
kid joe wrote:
>Hello,

I have seen the WndProc prototyped two ways,

LONG WINAPI WndProc ( .... );
and
LRESULT CALLBACK WndProc ( .... );

Are these functionally equivalent?

Under 32 bit windows they are equivalent.
Under 64 bit windows they are not since LRESULT
is a 64 bit type and LONG is a 32 bit type...

>What are WINAPI and CALLBACK defined as?

WINAPI is _stdcall in 32 Bit windows
CALLBACK is also defined as _stdcall.

Under 64 bit windows _stdcall doesn't exist
so both definitions are equivalent too,
probably defined as nothing.
Thanks a lot for the info.

I guess the only remaining question is, why are there these two different
prototypes for the same function, even if they're functionally equivalent?

Joe
--
.--------------------.
| |
| Good Evening.... | .--.--.
| | .; .;|;. ;.
`-------------. ,---' .;_;' `;_;.
\| ; ;' `; ;
\ ;;'.--.___.--.`;;
;-( o )=3D( o )-;
( `--' | `--' )
\| . . |/
........... . .:::::. . .______
/ . '---` . '\
.' `. .' \
| ____,.- . | `.....' | _______ |
| ,-' \ /|\'' \.-- |
| / \.'\ /,'. \. - |
| /| ` `\ / \ |
| ,/ _ '/ '\ |
,-' ,-. |o '
/ '| | | | \
/ ,/| |o | \ `
| .' | |.' |. \ \
________/ .'____|________ _______________ _||__`. `__________
( \ ) / )
'-. '-. ( .-` .-`
'-. .-'--.__. .-.__.--`-. .-`
'-..' \--' : ~`:=3D,`- `..-`
\ .. \\ |`-'|`-, /
\\\\\\\) | |`-'/.'/
\)\)\\ `-' `-'
`
Nov 1 '08 #4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

kid joe wrote:
I guess the only remaining question is, why are there these two different
prototypes for the same function, even if they're functionally equivalent?
Despite the fact that implementation is the same, semantic is different.
CALLBACK informs that it is callback function (called from winapi
libraries). LRESULT stands for long type that stores function's return
value. WINAPI is used for functions that are part of WinAPI. LONG is
just kind of type (that probably has the same size on all platforms).

MSDN states that the correct prototype is:
LRESULT CALLBACK WindowProc(...) ;
What fits my explanation of CALLBACK, WINAPI, LONG and LRESULT semantics.

These definitions allows to change implementation or hardware platform
without breaking API compliance.

Pawel Dziepak

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkk Mz5UACgkQPFW+cU iIHNrMVwCfSOOdF s3m1lMnNYDvtzfn MMWS
NgwAn1JPmkDB7Zk vrPFrAlvNSD6GH6 Rk
=sDyQ
-----END PGP SIGNATURE-----
Nov 1 '08 #5
kid joe wrote:
>
I guess the only remaining question is, why are there these two different
prototypes for the same function, even if they're functionally equivalent?
A windows group would be the place to ask.

Please don't post such a daft, ill-formed signature.

--
Ian Collins
Nov 1 '08 #6
Ian Collins wrote:
kid joe wrote:
>I guess the only remaining question is, why are there these two
different prototypes for the same function, even if they're
functionally equivalent?

A windows group would be the place to ask.

Please don't post such a daft, ill-formed signature.
He ignored the same request posted about 2 hours before his last
entry. If he continues again I guess the only solution is the
plonk file. Besides, his queries are all off-topic. He might read
the following references:

Some useful references about C:
<http://www.ungerhu.com/jxh/clc.welcome.txt >
<http://c-faq.com/ (C-faq)
<http://benpfaff.org/writings/clc/off-topic.html>
<http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf(C99)
<http://cbfalconer.home .att.net/download/n869_txt.bz2 (pre-C99)
<http://www.dinkumware. com/c99.aspx (C-library}
<http://gcc.gnu.org/onlinedocs/ (GNU docs)
<http://clc-wiki.net/wiki/C_community:com p.lang.c:Introd uction>

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.
Nov 2 '08 #7
Keith Thompson wrote:

And please use a shorter signature.
Or at the very least a legal signature separator.


Brian
Nov 2 '08 #8
On Sat, 01 Nov 2008 22:13:40 +0100, jacob navia wrote:
kid joe wrote:
>Hello,

I have seen the WndProc prototyped two ways,

LONG WINAPI WndProc ( .... );
and
LRESULT CALLBACK WndProc ( .... );

Are these functionally equivalent?

Under 32 bit windows they are equivalent.
Under 64 bit windows they are not since LRESULT
is a 64 bit type and LONG is a 32 bit type...

>What are WINAPI and CALLBACK defined as?

WINAPI is _stdcall in 32 Bit windows
CALLBACK is also defined as _stdcall.

Under 64 bit windows _stdcall doesn't exist
so both definitions are equivalent too,
probably defined as nothing.
But it's not just windows stuff.

There is an aspect of callback functions that is

a) metasyntactic
b) relevant to standard C
--
George

Hundreds of thousands of American servicemen and women are deployed across
the world in the war on terror. By bringing hope to the oppressed, and
delivering justice to the violent, they are making America more secure.
George W. Bush

Picture of the Day http://apod.nasa.gov/apod/
Nov 2 '08 #9
Default User wrote:
Keith Thompson wrote:

>And please use a shorter signature.

Or at the very least a legal signature separator.
And if the OP wonders how that looks like: It's
"-- \n", i.e. 2 dashes, 1 space 1 newline.

Wolfgang Draxinger
--
E-Mail address works, Jabber: he******@jabber .org, ICQ: 134682867

Nov 2 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
7149
by: scott ocamb | last post by:
hello I have implemented a solution using async methods. There is one async method that can be invoked multiple times, ie there are multiple async "threads" running at a time. When these threads are complete, the call the Callback method. Each "thread" calls the same callback method. What thread does this callback method exist on? My testing indicates the
4
2063
by: ma740988 | last post by:
// file sltest.h #ifndef SLTEST_H #define SLTEST_H class CallbackBase // herb shutters gotW source .. { public: virtual void operator()() const { }; virtual ~CallbackBase() = 0; };
15
2015
by: Felix Kater | last post by:
Hi, in a given library I register callback functions with this function: bool set_callback(int index, int (*callback_function)(long)); I need the callback function to also pass the index which is, however, not (re-)passed by the callback function. Normally, I would just register callback functions for each
2
1799
by: MR | last post by:
help! I have an unmanaged DLL that I do not have the source code, so i can't recompile or make changes. the DLL requires a callback function. I would like to implement the callback method in a managed class. The unmanaged DLL gets the address of the callback in a struct (someStruct below) that is passed as a parameter. I can't seem to figure out how to pass the "unmanaged" address of a managed method to be uses as a callback. I would...
6
7688
by: smmk25 | last post by:
Before I state the problem, I just want to let the readers know, I am knew to C++\CLI and interop so please forgive any newbie questions. I have a huge C library which I want to be able to use in a .NET application and thus am looking into writing a managed C++ wrapper for in vs2005. Furthermore, this library has many callback hooks which need to be implemented by the C++ wrapper. These callback functions are declared as "extern C...
10
7013
by: SQACPP | last post by:
Hi, I try to figure out how to use Callback procedure in a C++ form project The following code *work* perfectly on a console project #include "Windows.h" BOOL CALLBACK MyEnumWindowsProc(HWND hwnd, LPARAM lparam) {
0
2123
by: Tim Spens | last post by:
--- On Fri, 6/27/08, Tim Spens <t_spens@yahoo.comwrote: I think I know where the problem is but I'm unsure how to fix it. When I call Register_Handler(...) from python via callback.setHandler1(callback1) this only seems to affect pythons ability to trigger an "event" in c. PyObject *Handler is always NULL even after I call Register_Handler(...). I thought there was some magic here that was assigning the pointer *Handler to my python...
5
4326
by: Jef Driesen | last post by:
I have a C DLL that I want to use from a C# project. The C header file contains these declarations: typedef void (*callback_t) (const unsigned char *data, unsigned int size, void *userdata); void myfunction (callback_t callback, void *userdata); How do I translate this to C#? I tried with:
9
2279
by: Daniel Smedegaard Buus | last post by:
Hey all :) I was wondering about the $error_types (I particularly notice the 's' suffix when reading the manual) parameter for 'set_error_handler()': Can be used to mask the triggering of the error_handler function just like the error_reporting ini setting controls which errors are shown. Without this mask set the error_handler will be called for every error regardless to the setting of the error_reporting setting.
0
9933
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9779
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11114
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9563
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7960
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7114
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4605
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4205
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3230
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.