flat assembler
Message board for the users of flat assembler.
  
|  Index
      > Windows > GetDlgItem returns null | 
| Author | 
 | 
| macomics 12 Feb 2022, 11:42 Code: invoke GetDlgItem,[hwnd],2001 ;text box hwnd i'm trying to retrieve ; invoke GetLastError invoke GetWindowTextLength,eax Code: invoke GetDlgItem,[hwnd],2001 ;text box hwnd i'm trying to retrieve push eax invoke GetLastError invoke GetWindowTextLength | |||
|  12 Feb 2022, 11:42 | 
 | 
| extra_12345 12 Feb 2022, 13:23 yeah i know that the problem is :
 invoke GetDlgItem,[hwnd],2001 returns 0 and getlasterror returns = 1421 (0x58D) - Control ID not found | |||
|  12 Feb 2022, 13:23 | 
 | 
| FlierMate 12 Feb 2022, 15:13 I am newbie to Win32Dlg but after comparing with tutorial & example code, your code actually work but I need to modify the resource file.
 Code: .if [wparam] = 1000 ; button id invoke GetDlgItem,[hwnd],2001 ;text box hwnd i'm trying to retrieve ;invoke GetLastError ;invoke GetWindowTextLength,eax invoke GetWindowText,eax,Buffer,255 invoke MessageBox,[hwnd],Buffer,'',MB_OK .endif Code: section '.data' data readable writeable Buffer rb 255 I could not find "misc\macro.inc". And below is my modification to your resource section: Code: section '.rsrc' resource data readable directory RT_DIALOG,dialogs resource dialogs,\ 100,LANG_NEUTRAL+SUBLANG_NEUTRAL,demonstration dialog demonstration,'String Encrypt',0, 0, 331, 105,DS_MODALFRAME or DS_CENTER or WS_SYSMENU or WS_DLGFRAME or WS_BORDER or WS_VISIBLE or WS_POPUP dialogitem 'BUTTON','Encrypt',1000,237, 60, 60, 25,BS_PUSHBUTTON + BS_LEFT + BS_RIGHT + BS_TOP + BS_BOTTOM + WS_TABSTOP + WS_VISIBLE + WS_CHILD dialogitem 'EDIT','',2001, 27, 20, 177, 28,ES_LEFT + ES_AUTOHSCROLL + WS_TABSTOP + WS_VISIBLE + WS_CHILD dialogitem 'EDIT','',2002, 27, 58, 177, 28,ES_LEFT + ES_AUTOHSCROLL + WS_TABSTOP + WS_VISIBLE + WS_CHILD dialogitem 'EDIT','',2003, 238, 21, 54, 26,ES_LEFT + ES_AUTOHSCROLL + WS_TABSTOP + WS_VISIBLE + WS_CHILD enddialog After clicking the "Encrypt" button, a message box will pop up showing the text content of top left text box (2001). Sorry if this is not helpful. 
 | ||||||||||
|  12 Feb 2022, 15:13 | 
 | |||||||||
| macomics 12 Feb 2022, 18:19 extra_12345 wrote: yeah i know that the problem is : You can do without it. Just use the EnumChildWindows function to find all child windows. Next, check the parameters: Code: invoke EnumChildWindows, [hwnd], EnumCheckProc, NULL ... proc EnumCheckProc, ..., hChild, lParam invoke GetWindowLong, [hChild], GWL_ID cmp eax, 2001 ... | |||
|  12 Feb 2022, 18:19 | 
 | 
| Walter 12 Feb 2022, 19:28 This works for me.  Something to do with resource file?
  [/img] 
 | |||||||||||
|  12 Feb 2022, 19:28 | 
 | 
| extra_12345 12 Feb 2022, 23:27 thanks for the help ,yeah i think definitely it has something to do with my resource files.
 i've used EnumChildWindows and a debugger to check the hwnd of the controls in the EnumChildProc callback function and surprisingly it returned 0xFFFF07D3 instead of just 0x07D3 for the text box dunno why. | |||
|  12 Feb 2022, 23:27 | 
 | 
| extra_12345 12 Feb 2022, 23:30 macomics wrote: 
 sorry i forgot,here's the resource file. 
 | |||||||||||
|  12 Feb 2022, 23:30 | 
 | 
| macomics 13 Feb 2022, 00:18 I can guess that you are using a 16-bit resource generator. Though on new computers, they are in theory no longer launched. At a minimum, window IDs are created with the 0xFFFF bit extension. Last edited by macomics on 29 Jun 2022, 12:13; edited 1 time in total | |||
|  13 Feb 2022, 00:18 | 
 | 
| extra_12345 13 Feb 2022, 01:25 wow never thought of that,thanks,btw is there any good resource generator that i could use to generate 32 bit resource file? | |||
|  13 Feb 2022, 01:25 | 
 | 
| macomics 13 Feb 2022, 01:47 extra_12345 wrote: wow never thought of that,thanks,btw is there any good resource generator that i could use to generate 32 bit resource file? FlierMate wrote: 
 | |||
|  13 Feb 2022, 01:47 | 
 | 
| < Last Thread | Next Thread > | 
| Forum Rules: 
 | 
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.