One can do this:
case WM_COMMAND:
if (WORD wNotifyCode = HIWORD(wparam))
{
...
}
And one can do this:
case WM_COMMAND:
{
WORD wNotifyCode = HIWORD(wparam);
if (wNotifyCode > 1) {
...
}
}
But one cannot do:
case WM_COMMAND:
if ((WORD wNotifyCode = HIWORD(wparam)) > 1)
{
...
}
Using a for statement here I think is misleading:
case WM_COMMAND:
for (WORD wNotifyCode = HIWORD(wparam); wNotifyCode > 1; wNotifyCode = 0)
{
...
}
Because it looks a lot like a loop is happening - and the poor schmuck who comes after me has to decipher this garbage.
But is there no syntactic construct which combines the elegance of an if-statement that includes a local variable declaration with the ability to test its value for something other than zero?