hey Im trying to get this to work but for some reason it adds 50 instead of one then after it adds 50 its starts adding one. here is the code:


include windows.inc
include user32.inc
include kernel32.inc
include shell32.inc
include comctl32.inc
include comdlg32.inc

includelib user32.lib
includelib kernel32.lib
includelib shell32.lib
includelib comctl32.lib
includelib comdlg32.lib

WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD

.const

IDC_EDT1 equ 1001
IDC_BTN1 equ 1002
IDC_BTN2 equ 1003

.data

ClassName db 'DLGCLASS',0
DlgName db 'MyDialog',0
AppName db 'Dialog as main',0
number1 db '1',0

.data?

hInstance dd ?
CommandLine dd ?
hWnd dd ?
number dd ?




WndProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

mov eax,uMsg
.if eax==WM_INITDIALOG
push hWin
pop hWnd
invoke SetDlgItemText,hWin,IDC_EDT1,addr number1
invoke GetDlgItemText,hWin,IDC_EDT1,addr number,sizeof number
.elseif eax==WM_COMMAND
mov eax,wParam
and eax,0FFFFh
.if wParam==1002
add number,1
mov eax,number
invoke SetDlgItemInt,hWin,IDC_EDT1,eax,NULL

.endif
; .elseif eax==WM_SIZE
.elseif eax==WM_CLOSE
invoke DestroyWindow,hWin
.elseif uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.else
invoke DefWindowProc,hWin,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret

WndProc endp

end start

anyone know why it adds 50 first?
Posted on 2002-08-16 23:27:38 by resistance_is_futile

anyone know why it adds 50 first?


Your number db "1" is not actually a 1, for it is a string composed of a byte, with a value of 031h, or, what is the same, 49.
Posted on 2002-08-16 23:40:34 by CodeLover
number1 db '1',0

'1' String character = 49 decimal

Use number1 db 0
Posted on 2002-08-16 23:44:33 by WillASM
okay thanks. I was going to use number 1 db 001h,0 but that made a weird symbol come up when i first started the proggie. Thx again guys.
Posted on 2002-08-16 23:49:16 by resistance_is_futile
You don't show where you initialize number.

number dd ?

is not guaranteed to start with 0.
Posted on 2002-08-18 10:52:14 by tenkey

okay thanks. I was going to use number 1 db 001h,0 but that made a weird symbol come up when i first started the proggie. Thx again guys.

That's because you SetDlgItemText instead of SetDlgItemInt...


number dd ?
is not guaranteed to start with 0.

Dunno if it's guaranteed anywhere (and too lazy to browse MSDN), but uninitialized data *will* end up zeroed because of the way images are loaded. Guess its sloppy coding practice to rely on this, though.
Posted on 2002-08-18 11:05:15 by f0dder