Hi HSE
I modified the EdDec file, so it works for you. I intoduced some changes to work with Unicode or ANSI Chars.
Use the DBG macros to inspect the content of your structures and strings.
; ==================================================================================================
; Title: EdDec.inc
; ==================================================================================================
DEF_EdDec struc
dCtlID DWORD ? ;Contol ID
dStyle DWORD ? ;Style
dExStyle DWORD ? ;Extended style
pTitle PSTRING ? ;-> Window title
sdPosX SDWORD ? ;X position
sdPosY SDWORD ? ;Y position
dWidth DWORD ? ;Width
dHeight DWORD ? ;Height
DEF_EdDec ends
PDEF_EdDec typedef ptr DEF_EdDec
; ——————————————————————————————————————————————————————————————————————————————————————————————————
; Object: EdiDec
; Purpose: Implement a thin wrapper around the Edit GDI object.
Object EdDec, EdDecID , WinControl ;Class "EdDec"
RedefineMethod Done
RedefineMethod Init, POINTER, HWND, PDEF_EdDec
RedefineMethod WndProc, DWORD, WPARAM, LPARAM
DefineVariable Buffer1 ,BYTE, 32 dup (0) ; numeros con decimales
ObjectEnd
; ==================================================================================================
if IMPLEMENT
; ——————————————————————————————————————————————————————————————————————————————————————————————————
; Method: Edit.Done
; Purpose: Finalize the Edit object.
; Arguments: None.
; Return: Nothing.
Method EdDec.Done, uses esi
SetObject esi
Unsubclass EdDec ;Uses esi
ACall esi.Done
MethodEnd
; ——————————————————————————————————————————————————————————————————————————————————————————————————
; Method: EdiDec.Init
; Purpose: Initialize the Edit object.
; Arguments: Arg1: -> Owner object.
; Arg2: Parent window HANDLE.
; Arg3: -> DEF_Edit initialization structure.
; Return: Nothing.
Method EdDec.Init, uses esi, pOwner:POINTER, hParent:HWND, pDefStruc:PDEF_EdDec
SetObject esi
mov ecx, pDefStruc
assume ecx:PDEF_EdDec
mov eax, [ecx].dStyle
or eax, WS_VISIBLE or WS_CHILD or \
ES_AUTOHSCROLL or ES_NOHIDESEL
invoke CreateWindowEx, [ecx].dExStyle, $OfsCStr("EDIT"), [ecx].pTitle, eax, \
[ecx].sdPosX, [ecx].sdPosY, [ecx].dWidth, [ecx].dHeight, \
hParent, [ecx].dCtlID, hInstance, 0
assume ecx:NOTHING
ACall esi.Init, pOwner, eax
Subclass EdDec ;Uses esi
MethodEnd
; ——————————————————————————————————————————————————————————————————————————————————————————————————
; Method: EdiDec.WndProc
; Purpose: Processing of window messages. Before invoking it, the window must be subclassed.
; Arguments: Arg1: Message identifier.
; Arg2: First message parameter.
; Arg3: Second message parameter.
; Return: eax = This value is the result of the message processing and depends on the message ID.
; Note: Window HANDLE is passed in pSelf (hidden argument).
Method EdDec.WndProc, uses esi, uMsg:DWORD, wParam:WPARAM, lParam:LPARAM
local cBuffer[32]:CHR ; numeros con decimales
GetSubclassingInst EdDec, pSelf
SetObject esi, EdDec, eax
.if uMsg == WM_CHAR
.if wParam == 8 ; backspace
jmp accept
.endif
.if wParam == "." ; only allow one decimal point
; invoke SendMessage, [esi].hWnd, WM_GETTEXT, lengthof cBuffer, addr cBuffer
invoke CallWindowProc, [esi].pPrevWndProc, [esi].hWnd, WM_GETTEXT, lengthof cBuffer, addr cBuffer
DbgHex eax
DbgStr cBuffer
invoke StrScan, addr cBuffer, 2Eh
.if eax > 0
return 0
.endif
jmp accept
.endif
.if wParam < "0"
return 0
.endif
.if wParam > "9"
return 0
.endif
.endif
accept:
OCall esi::EdDec.Dispatch, pSelf, uMsg, wParam, lParam
MethodEnd
endif
Biterider