It beeps because, being a single line, pressing enter is considered an attempt to insert another line.
On dialog boxes, the Enter key is trapped by the dialog procedure and sent to the default pushbutton (if any), otherwise left to the edit control itself.
On other window, such "trapping" requires a messge-loop that check the presence of a dialog message before dispatching to the focused window.
Something like
LRESULT WINAPI CALLBACK winproc(HWND h, UINT m, WPARAM w, LPARAM z)
{
....
}
int main()
{
WNDCLASSEX wcx = { ..... };
....
RegisterWindowClassEx(&wcx);
HWND hwnd = CreateWindow( .... );
....
for(;;)
{
MSG msg;
if(GetMessage(&msg,0,0,0)<=0) break;
if(IsDialogMessage(hwnd,&msg)) continue;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}