Microsoft provides a number of #defines in their Windows API header files to make programming Windows applications portable across OS versions.
You are going to get a fairly technical answer because you are asking fairly technical questions.
A
calling convention is the way in which a function is called. There are several things to account for when a function is called, but the most important are: how are the arguments passed to the function and how is the result returned?
WINAPI and CALLBACK are found in
windef.h as
1 2
|
#define WINAPI __stdcall
#define CALLBACK __stdcall
|
There are others, but Win32 functions are almost always stdcall. What the "standard calling" convention means is basically that:
1. All the function's arguments are pushed onto the stack in reverse order.
2. The function pops the arguments off the stack when it returns.
3. The result is returned in EAX or EDX:EAX depending on its size.
(There are variations for non-integer results, but you can forget it for now.)
For example, if I were to call a function
int foo( int a, char b );
as
x = ( 42, 'A' );
that would generate machine code that looks something like the following (simplified):
1 2 3 4
|
PUSH 'A'
PUSH 42
CALL @__foo
MOV EAX --> [x]
|
Since the function pops all the arguments, line 4 didn't need to be preceeded by any code that popped the 42 and 'A' from the stack (it was already done). The result value was put in the EAX register, so we stored its value in the memory location at x.
Return values in C and C++ are expressed before the function name. In the above example,
foo() returned an
integer. Hence, the function was typed (or "prototyped") as:
int foo( int a, char b );
Again, the windows headers #define values to make life easier. LRESULT ultimately evaluates to essentially
#define __int64 LRESULT
So a LRESULT value is a 64-bit integer, meaning that
WinMain() returns a 64-bit integer to the OS.
The difference between
window styles and
extended window styles is that extended window styles are additional (or new) window styles that didn't exist when the original window styles were first created.
Virtual key codes are a way of tracking which keys are pressed or released (or auto-repeating) from the keyboard. Keyboards don't actually send ASCII characters to the computer. That is, pressing the 'A' key doesn't send an 'A' to the computer. It sends a number. Different keyboards may send different numbers. (PC keyboards tend to all use the same number, but that is beside the point.)
Windows takes that number and converts it into
another number: the Virtual Key code. Applications that use the Win32 API can then use these
known numbers (because they are pre-defined to be the same thing no matter what the actual hardware attached to the computer is) to determine the state of the keyboard keys.
For standard I/O streams and other character applications, these Virtual Key codes are translated into the ASCII character codes we all know and love. Raw key messages (obtained from
GetMessage()) don't have that extra information, so
TranslateMessage() must be used to recognize key messages and modify them to have that extra, useful, friendly information.
Messages are the way in which Windows communicates with applications. Applications, by themselves, typically don't have direct access to the hardware. (For reasons I won't go into, that is a Good Thing.)
Windows, as the
Operating System --meaning it operates (or manages) the computer system (hardware and software), is a kind of translator between the hardware and the application software.
An analogy would be something to the effect of someone from the UK going to Mexico as part of a business deal. While in Mexico, the English-speaking brit has no clue what the locals are saying. He needs someone to translate for him. So if the brit were to say "you're stupid" the translator would have the tact to say "no me cae bien". If he were in Japan he might get a more literal translation: "baka na". But the effect on the recipient is the same in both cases.
A messages is composed of three parts: the message code (what kind of message it is), and two additional codes that have meaning based upon the message. Read more here:
http://winprog.org/tutorial/message_loop.html
Well, that's about it. Good luck!