flat assembler
Message board for the users of flat assembler.

Index > Windows > GetDlgItemInt returns control ID not found

Author
Thread Post new topic Reply to topic
FoZZiE



Joined: 26 Jan 2007
Posts: 2
FoZZiE 26 Jan 2007, 22:00
Basically I decided to start learning asm a few days ago and as a learning task I chose to make a calculator as it seemed quite a basic program. I already know c++ so API calls aren't a problem and neither is the GUI. I'm trying to use GetDlgItemInt to get the number input in each of the 2 text boxes but it won't work. I've been doing some debugging with ollydbg and the correct control ID is set when the window is created and it matches the control ID made in the API call but it returns an error of control ID not found. I have been running through this code for hours now and I just can't see why it isn't working. The, probably quite badly coded, source code is attached. Can anyone help me with this please?


Description:
Download
Filename: Calculator.txt
Filesize: 4.61 KB
Downloaded: 311 Time(s)

Post 26 Jan 2007, 22:00
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 26 Jan 2007, 22:28
You are using the functions wrong. The first parameter should be the hwnd of the window.

This works:
Code:
        .addthem:              ; + function
                invoke GetDlgItemInt, [hWindow],numaID,NULL,FALSE ; 1st textbox
                ;cmp eax,0
                ;je .worked
                mov [numaint],eax                                  ; store return value
                invoke GetDlgItemInt,[hWindow],numbID,NULL,FALSE  ; 2nd textbox
                add eax,[numaint]                                  ; add values
                invoke SetDlgItemInt,[hWindow],answerID,eax,1   ; set the answer
                jmp .finish    


So remember to save the hWnd of the window to hWindow variable.
Post 26 Jan 2007, 22:28
View user's profile Send private message Reply with quote
FoZZiE



Joined: 26 Jan 2007
Posts: 2
FoZZiE 26 Jan 2007, 22:36
Embarassed Embarassed no idea why i didn't realise that. Thanks alot I can get on with the rest of it now Very Happy
Post 26 Jan 2007, 22:36
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 26 Jan 2007, 23:18
BTW, consider creating the dialog like the DIALOG example included in the package instead of doing it manually or use another tool for creating the dialog and RES file and then use "section '.rsrc' data readable resource from 'my.res'".

PS: The documentation for creating dialog resources is http://flatassembler.net/docs.php?article=win32
Post 26 Jan 2007, 23:18
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.