Hello everyone, I have some confusion regarding some Win32 API data types and macros that we use-:
Firstly-: Regarding the WM_NOTIFY message. The lparam contains the pointer to the NMHDR structure. So if its a pointer why is it illegal to access the NMHDR structure like this-:
(*lparam)->idFrom
I mean if its a pointer then I could just use an indirection operator to get to the structure. LPARAM is itself typedefed from LONG_PTR. Why do I have to write the code like this-:
((LPNMHDR)lparam)->idFrom
What is LPNMHDR? LPNMHDR is typedefed in the following way-:
typedef NMHDR FAR * LPNMHDR;
FAR* is again defined in the following way-:
#define FAR _far
What is _far and why to I have to use LPNMHDR cast to access the NMHDR structure from LPARAM?
Secondly-: What does the MAKEINTRESOURCE macro do? I have seen a lot of authors use a plain string when specifying resources to functions. For example-:
CreateDialog(hInst,"Dialog Box",
hwnd,(DLGPROC)DialogFunc);
But in modern compilers we use-:
CreateDialog(hInst,MAKEINTRESOURCE(DIALOG_BOX),
hwnd,(DLGPROC)DialogFunc);
I know that if we use a string identifier in the resource file instead of a number then we can omit this macro so does this macro convert a number to a string. For example does it convert 23 into "23"?? Because if it did then I would be able to use -:
CreateDialog(hInst,"23",
hwnd,(DLGPROC)DialogFunc);
if my dialog box resource was defined with 23. But this doesn't work.
So I want to know what is the outcome after this macro processes an identifier? How does it work? What would I have to do in order to print the value of the MAKEINTRESOURCE in a message box because I am facing problems while copying the value to a string using the the sprintf function. But I know that MAKEINTRESOURCE outputs a LPSTR because it is defined in the following way-:
#define MAKEINTRESOURCEA(i) ((LPSTR)((ULONG_PTR)((WORD)(i))))
I have not yet found any documentation on how this macro works. The msdn states that MAKEINTRESOURCE is a macro which 'converts an integer value to a resource type compatible with the resource-management functions'. Thank You.