|
发表于 2011-7-7 14:26:00
|
显示全部楼层
Re:WIn32API编程高手进
- WNDPROC oldProc = NULL;
- INT_PTR CALLBACK EditProc(HWND hEdit, UINT message, WPARAM wParam, LPARAM lParam)
- {
- if (message == WM_CHAR)
- {
- int c = (int)wParam;
- if (c != VK_BACK && c != '.' && (c < '0' || c > '9'))
- return (INT_PTR)TRUE;
- }
- return CallWindowProc(oldProc, hEdit, message, wParam, lParam);
- }
- INT_PTR CALLBACK DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
- {
- UNREFERENCED_PARAMETER(lParam);
- switch (message)
- {
- case WM_INITDIALOG:
- {
- HWND hEdit = ::GetDlgItem(hDlg, IDC_EDIT1);
- if (hEdit)
- {
- oldProc = (WNDPROC)::SetWindowLong(hEdit, GWL_WNDPROC, (long)EditProc);
- }
- }
- return (INT_PTR)TRUE;
- case WM_COMMAND:
- if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
- {
- EndDialog(hDlg, LOWORD(wParam));
- return (INT_PTR)TRUE;
- }
- break;
- }
- return (INT_PTR)FALSE;
- }
- int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
- {
- return DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DlgProc);
- }
复制代码
大概是这意思。不过这样不够,因为能输入多个小数点 |
|