Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compile Exe
#Dim All
#Include "Win32API.inc"
Global hDlg As Dword, OldProc&
%IDC_TextBox = 500
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,205, %WS_OverlappedWindow To hDlg
Control Add TextBox, hDlg, %IDC_TextBox, "Sample Text", 15,10,170,50
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case Cb.Msg
Case %WM_InitDialog
OldProc& = SetWindowLong(GetDlgItem(hDlg, %IDC_TextBox), %GWL_WndProc, CodePtr(NewProc)) 'subclass
Case %WM_Destroy
SetWindowLong GetDlgItem(hDlg, %IDC_TextBox), %GWL_WNDPROC, OldProc& 'un-subclass
End Select
End Function
Function NewProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case Msg
Case %WM_Char
If wParam = 8 Then Exit Select 'allow backspace
If wParam = 46 Then Exit Select 'allow decimal
If wParam <= 57 And wParam >= 48 Then Exit Select 'allow 0-9
Exit Function
End Select
Function = CallWindowProc(OldProc&, hWnd, Msg, wParam, lParam)
End Function
'gbs_01256
'Date: 05-11-2013
http://www.garybeene.com/sw/gbsnippets.htm