有关SetDlgItemInt函数在WM_COMMAND消息下导致程序无响应的有关问题

有关SetDlgItemInt函数在WM_COMMAND消息下导致程序无响应的问题
源程序:
#include <windows.h>
#include "resource.h"

LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
{
HWND hwnd;
WNDCLASS wndclass;
MSG msg;

wndclass.cbClsExtra =0;
wndclass.cbWndExtra =DLGWINDOWEXTRA;
wndclass.hbrBackground =(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hCursor =LoadCursor(NULL,IDC_ARROW);
wndclass.hIcon =LoadIcon(NULL,IDI_APPLICATION);
wndclass.hInstance =hInstance;
wndclass.lpfnWndProc =WndProc;
wndclass.lpszClassName=TEXT("MyWindow");
wndclass.lpszMenuName =NULL;
wndclass.style =CS_VREDRAW|CS_HREDRAW;

if(!RegisterClass(&wndclass))
{
MessageBox(NULL,"注册失败!","警告",MB_ICONERROR|MB_OK);
return 0;
}

hwnd=CreateDialog(hInstance,wndclass.lpszClassName ,0,NULL);

ShowWindow(hwnd,nShowCmd);

while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam ;
}

LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_CHAR:
SendMessage(GetDlgItem(hwnd,(int)wParam),BM_SETSTATE,1,0);
Sleep(100);
SendMessage(GetDlgItem(hwnd,(int)wParam),BM_SETSTATE,0,0);
SetDlgItemInt(hwnd,IDC_EDIT,(int)wParam-48,TRUE);
return 0;

case WM_COMMAND:
SetFocus(hwnd);
return 0;

case WM_DESTROY:
PostQuitMessage(0);
return 0;
}

return DefWindowProc(hwnd,message,wParam,lParam);
}

当在WM_COMMAND消息下添加 SetDlgItemInt(hwnd,IDC_EDIT,(int)LOWORD(wParam)-48,TRUE);后运行程序,会出现在点击了按钮以后程序无响应的现象,求解释。

resource.h
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by 计算器.rc
//
#define _DC_NUM1                        1
#define IDC_NUM1                        1
#define IDC_EDIT1                       1000
#define IDC_EDIT                        1000
#define IDC_NUM2                        1002
#define IDC_NUM3                        1003
#define IDC_NUM4                        1004
#define IDC_NUM5                        1005
#define IDC_NUM6                        1006
#define IDC_NUM7                        1007
#define IDC_NUM8                        1008
#define IDC_NUM9                        1009
#define IDC_NUM0                        1010
#define IDC_PLUS                        1011
#define IDC_EQUAL                       1012

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        102
#define _APS_NEXT_COMMAND_VALUE         40001
#define _APS_NEXT_CONTROL_VALUE         1002
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

rc文件里的部分代码:
MYWINDOW DIALOG DISCARDABLE  0, 0, 208, 193
STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
CLASS "MyWindow"
FONT 10, "System"
BEGIN
    EDITTEXT        IDC_EDIT,36,24,102,18,ES_AUTOHSCROLL
    PUSHBUTTON      "1",49,27,52,35,18