|
From: <or...@vp...> - 2002-12-06 19:01:12
|
Hello!
Anders Eriksson wrote:
> You can't introduce new variables in a switch! Move the DWORD style;
> outside and above the switch statement.
Well, that is not exactly true, because you can intorduce variables
wherever you want. You only need to put the declaration with the
corresponding code into a block. So this is also valid:
switch(msg) {
case WM_CREATE:
{ /* --- start of block --- */
DWORD style;
style = (WS_CHILD | WS_VISIBLE); //and others
// ... other code
} /* --- end of block --- */
case WM_DROPFILES:
// ... other code
}
This way you can use local variables, but be aware that the variable you
declared this way is only valid until the end of the block, which it is
in (this case, until the end of the case).
Also this way is better, than putting things before the switch, because
it will be very annoying to scroll up to the beginning of the switch,
when it is VERY long. (Trust me, it WILL be very long)
Of course you are still restricted to place your declarations at the
beginning of the blocks.
If you want to declare anywhere, anytime without blocks, and
restrictions, use C++ :)
--
Best regards
OROSZI Balázs
|