如何将编辑框转换为数字组件?
How to convert an editbox to a number assembly?
在 Win32 的 TASM 中,我有这个代码:
;------- Edit1 Create ----------------
push L 0
push [hInstEdit1]
push idEdit1
push [newhwnd]
push L 20
push L 200
push L 50
push L 130
push L WS_CHILD+WS_VISIBLE+WS_BORDER+ES_LEFT+ES_NOHIDESEL+ES_AUTOHSCROLL
push L 0
push offset EClassName
push L 0
call CreateWindowEx
mov [hEdit1],EAX
push L SW_SHOW
push [hEdit1]
call ShowWindow
push [hEdit1]
call UpdateWindow
我需要获取用户在此编辑框中输入的数字。
该号码必须放在寄存器中。
谁知道怎么做?
PS 我认为您需要使用函数 GetDlgItemInt
这是网上找到的方法
; Input:
mov esi, offset szMsg1 ; esi - str
dec msgLength
mov ecx, msgLength ; ecx - length str
; Output:
; EAX = integer value
string_to_int:
xor ebx,ebx ; clear ebx
next_digit:
movzx eax, byte ptr [esi]
inc esi
sub al,'0' ; convert from ASCII to number
imul ebx,10
add ebx,eax ; ebx = ebx*10 + eax
loop next_digit ; while (--ecx)
mov eax,ebx
在 Win32 的 TASM 中,我有这个代码:
;------- Edit1 Create ----------------
push L 0
push [hInstEdit1]
push idEdit1
push [newhwnd]
push L 20
push L 200
push L 50
push L 130
push L WS_CHILD+WS_VISIBLE+WS_BORDER+ES_LEFT+ES_NOHIDESEL+ES_AUTOHSCROLL
push L 0
push offset EClassName
push L 0
call CreateWindowEx
mov [hEdit1],EAX
push L SW_SHOW
push [hEdit1]
call ShowWindow
push [hEdit1]
call UpdateWindow
我需要获取用户在此编辑框中输入的数字。 该号码必须放在寄存器中。 谁知道怎么做?
PS 我认为您需要使用函数 GetDlgItemInt
这是网上找到的方法
; Input:
mov esi, offset szMsg1 ; esi - str
dec msgLength
mov ecx, msgLength ; ecx - length str
; Output:
; EAX = integer value
string_to_int:
xor ebx,ebx ; clear ebx
next_digit:
movzx eax, byte ptr [esi]
inc esi
sub al,'0' ; convert from ASCII to number
imul ebx,10
add ebx,eax ; ebx = ebx*10 + eax
loop next_digit ; while (--ecx)
mov eax,ebx