1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
// Test.c
#include <windows.h>
WNDPROC OldEditProc;
//-----------------------------------------------------------------
LRESULT CALLBACK EditProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
switch(msg)
{
case WM_PASTE:
return 1;
case WM_CHAR:
if((wp < '0' || wp > '9') && wp != '.' && wp != '\b')
return 1;
}
return CallWindowProc(OldEditProc, hWnd, msg, wp, lp);
}
//-------------------------------------------------------------
BOOL CALLBACK DlgProc(HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
{
switch(msg)
{
case WM_INITDIALOG:
OldEditProc = (WNDPROC)SetWindowLong(GetDlgItem(hDlg, 1000), GWL_WNDPROC, (long)EditProc);
return TRUE;
case WM_CLOSE:
EndDialog(hDlg,0);
return TRUE;
}
return FALSE;
}
//-------------------------------------------------------------
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE x, LPSTR y, int z)
{
return DialogBox(hInst, "Dlg", 0, DlgProc);
} |
Partager