使用阻止Enter键的编辑控件的简单子类来完成此操作:
LRESULT CALLBACK EditSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
{
if (uMsg == WM_CHAR && wParam == VK_RETURN)
return ;
LRESULT lRes = DefSubclassProc(hWnd, uMsg, wParam, lParam);
if (uMsg == WM_DESTROY)
RemoveWindowSubclass(hWnd, EditSubclassProc, );
return lRes;
}
调用它:
SetWindowSubclass(hWndEdit, EditSubclassProc, , );