What IDs did you give hwnddateEdit, hwndEdit, hwndbutton and hwndMonthCal?
Do you think that this will cause issues when using the ID to switch in the WM_COMMAND handler? (assuming Windows allows you to create the controls in the first place)
BTW I am not using a complier to find these errors, I am just carefully reading your code.
EDIT:
You are not returning a value after processing a msg but letting it fall thru to the default msg handler.
Returning a value (and not calling the default handler) is required.
The return varies depending on the msg type (WM_COMMAND req a 0 return to show you handled the msg).
This is because some of your functions say they return an int but do not actually have a 'return iValue;' call in them. But as you have defined them as return'ing an int sized block of memory, some random number probably will be returned (and you use this random return).
Check my code, you will see I return'ed a value to show I had handled each msg.
I also ensured that the default handler was only called if I did not handle the msg.