WNDPROC oldWndProc;
LRESULT CALLBACK SubClassFunc(HWND hWnd,UINT Message,WPARAM wParam,LPARAM lParam)
{
if(Message==WM_CHAR&& wParam != '.' && (wParam <= '0' || wParam >= '9') && wParam != VK_BACK)
{
MessageBox(NULL,"数字","数字",0);
return 0;
}
else
return CallWindowProc(oldWndProc,hWnd,Message,wParam,lParam);
}
上面两个是全局的
OnInitDialog()
{
................
oldWndProc=( WNDPROC)SetWindowLong(
::GetDlgItem(this->m_hWnd,IDC_EDIT1),GWL_WNDPROC,(DWORD)SubClassFunc);
..............
}