Hello. By creating a "simple dialog based application", code for
WinMain is generated.
Inside
WinMain the following lines of code can be found:
/* Get system dialog information */
wcx.cbSize = sizeof(wcx);
if (!GetClassInfoEx(NULL, MAKEINTRESOURCE(32770), &wcx))
return 0;
Questions:
- Why is the 32770 magic number used?
- What does the if statement check?
It checks the presence of the dialog class.
Quote#32770 The class for a dialog box.
https://msdn.microsoft.com/en-us/library/windows/desktop/ms633574%28v=vs.85%29.aspx
Quote from: Snowman on March 31, 2015, 03:42:15 PM
Questions:
- Why is the 32770 magic number used?
- What does the if statement check?
As already said by JJ #32770 is the name of the dialog windows class. Because you want create such kind of window you'll use the function GetClassInfoEx to get all class informations to use for our new window.
To be sure that we get correct class data we have to check which value is returned from the function. GetClassInfoEx returns 0 if it fails (class data is not valid) or a value>0 if success.
The form:
if (something)
in C is TRUE if something <>0. The estended form should be:
if (something != 0)
Which is equivalent to the former.
The operator ! negates the logical value: TRUE became FALSE and the reverse. So:
if (!GetClassInfoEx(NULL, MAKEINTRESOURCE(32770), &wcx))
return 0;
Works this way:
- Executes the function
- Invert the result of function (fail becomes TRUE)
- if function fails exit program with vallue 0 (return 0;)
Thanks for your replies. (I know this post is a bit pointless but this forum has no "Thanks" button.)