flat assembler
Message board for the users of flat assembler.

Index > Windows > Subclass edit control

Author
Thread Post new topic Reply to topic
Synaps3



Joined: 06 Jul 2011
Posts: 6
Synaps3
I am trying to subclass an edit control so that I can detect when a key is pressed in the control. I have some code that is not working.

Code:
;=======================================================================
format PE GUI 4.0
;=======================================================================
include 'win32ax.inc'    ;*
include 'rc.inc'        ;*
;=======================================================================
section '.code' code readable executable

entry $

    invoke GetModuleHandle,0
    mov [hInstance],eax
    invoke DialogBoxParam,eax,D_MAIN,0,dlg_proc,0
    invoke ExitProcess,0

;=======================================================================
proc dlg_proc, hWnd, uMsg, wParam, lParam
    cmp [uMsg],WM_CLOSE
    jne @F
.end_dlg:
    invoke EndDialog,[hWnd],0
.exit_true:
    mov eax,TRUE
    ret
@@:
;-----------------------------------------------------------------------
    cmp [uMsg],WM_INITDIALOG
    jne @F
    invoke GetDlgItem,[hWnd],EDIT_1
    mov [hwndEdit],eax
    invoke SetWindowLong,hwndEdit,GWL_WNDPROC,dword [TheEditProc]
    mov [OldWndProc],eax
    jmp .exit_true
@@:
.exit_false:
    xor eax,eax
    ret
endp
;=======================================================================
proc TheEditProc, hWnd, uMsg, wParam, lParam
    cmp [uMsg],WM_CHAR
    jne @F
    invoke MessageBox,NULL,"fhuiahei","hfeihfwauif",MB_ICONINFORMATION
@@:
    invoke CallWindowProc,[OldWndProc],[hWnd],[uMsg],[wParam],[lParam]
    xor eax,eax
    ret
endp
    
Post 07 Jul 2011, 19:28
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17284
Location: In your JS exploiting you and your system
revolution
This looks more likely to work:
Code:
invoke SetWindowLong,[hwndEdit],GWL_WNDPROC,TheEditProc    
I haven't checked any of the other lines, so there might, or might not, be other problems. I couldn't test it because the code you posted is incomplete.
Post 07 Jul 2011, 19:35
View user's profile Send private message Visit poster's website Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
hmm odd
Post 07 Jul 2011, 23:02
View user's profile Send private message Reply with quote
FrozenKnight



Joined: 24 Jun 2005
Posts: 128
FrozenKnight
I have a working edit control subclass here.
i use the following code to set it up.
Code:
  push  IDI_FLOATNUMBER
  push  [hdlg]
  call  [GetDlgItem]
  push  fltedit_proc
  push  GWL_WNDPROC
  push  eax
  call  [SetWindowLong]
  cmp   eax, 0
  jz    .wmclose
  mov   [proc_edit], eax     


I don't really like using the invoke syntax, but i think that revolution probably caught your problem. Since the subclass i used appears closely related to what your doing i think my example may help a little with other issues. (again sorry about not using the familiar invoke but i really do prefer using the push/pop notation.)
Post 08 Jul 2011, 17:56
View user's profile Send private message Reply with quote
Synaps3



Joined: 06 Jul 2011
Posts: 6
Synaps3
I made the changes you suggested, it still doesn't work, but it did change. Now the edit control is unresponsive. The only way I can move the caret into it is by pressing the tab key, but when I try to type in the box, nothing happens. It doesn't accept text. Any other suggestions.

Thanks for the help.
Post 09 Jul 2011, 19:55
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
can you post rc.inc please
Post 09 Jul 2011, 21:18
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 764
Location: Massachusetts, USA
bitshifter
Also my BitBox utility uses EDIT subclassing.
It may provide some good reference.
I subclass two edit controls into one proc Smile
http://board.flatassembler.net/topic.php?t=11615
Post 10 Jul 2011, 16:40
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.