hey 2 problems,
1.
long ScanMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
switch (WM_COMMAND) {
case message:
should be
switch (message) {
case WM_COMMAND:
because the variable here is the message, WM_COMMAND is only a #defined constant
2. you are only handling WM_COMMAND message, there are alot of other possible messages could be goind around, so you should return a value fot hem. make the last default return 0;
that's all i guess.