flat assembler
Message board for the users of flat assembler.

Index > Windows > vk_escape

Author
Thread Post new topic Reply to topic
Crukko



Joined: 26 Nov 2005
Posts: 118
Crukko 08 Feb 2006, 12:52
uhmmm....I subclassed the WndProc....
but the new winproc doesn't get the wm_keydown msg when pressing escape...
Can someone help me?
It can't get also the vk_return msg..... Sad
Thx
Post 08 Feb 2006, 12:52
View user's profile Send private message Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 08 Feb 2006, 12:56
Maybe some child window traps this message?
Post 08 Feb 2006, 12:56
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 08 Feb 2006, 13:21
try to catch wm_command and check 1 for ok and 2 for esc (?) what a window subclassed: child on dialog?
Post 08 Feb 2006, 13:21
View user's profile Send private message Visit poster's website Reply with quote
Crukko



Joined: 26 Nov 2005
Posts: 118
Crukko 09 Feb 2006, 06:48
Decard: I don't know....may be....but wich one?

I think it's better put here the code Wink
Thx to Madis731 Wink

Code:
proc   WinConverterDialogProc hWnd,msg,wParam,lParam
    push    ebx edi            ;Preserve as needed
    cmp     [msg],WM_COMMAND   ;Are there any commands?
    je      command            ;then deal with them
    cmp     [msg],WM_CLOSE     ;or is it "close"?
    je      close              ;so, do it!
    cmp     [msg],WM_INITDIALOG
    je      initdialog
    xor     eax,eax
    jmp     processed
command:
    cmp     [wParam],EN_UPDATE shl 16 + ID_WINDEC
    je      parseD             ;compare and jump accordingly
    cmp     [wParam],EN_UPDATE shl 16 + ID_WINHEX
    je      parseH             ;H-hexadecimal
    cmp     [wParam],EN_UPDATE shl 16 + ID_WINBIN
    je      parseB             ;B-binary
    jmp     processed          ;If defaults have been re-set
;<<<-c800----CODE TO UPDATE CELLS WHEN TYPED---------------->>>
parseD:                        ;Jump from above commands
    jmp     processed          ;we are finished
parseH:
    jmp     processed
parseB:
    jmp     processed
initdialog:
    push    [hWnd]
    pop     [hWinConverterDialog]
    invoke  GetDlgItem, [hWnd], ID_WINDEC;get a handle and use it
    mov     [hwindec], eax
    invoke  GetDlgItem, [hWnd], ID_WINBIN;get a handle and use it
    mov     [hwinbin], eax
    invoke  GetDlgItem, [hWnd], ID_WINHEX;get a handle and use it
    mov     [hwinhex], eax
    invoke  GetDlgItem, [hWnd], ID_WINEXP;get a handle and use it
    mov     [hwinexp], eax
    invoke  SendMessage, [hWnd], WM_SETFONT, _lf, TRUE

            invoke  SendMessage, [hwindec], EM_SETLIMITTEXT, 10, 0
            invoke  SendMessage, [hwinhex], EM_SETLIMITTEXT, 8, 0
            invoke  SendMessage, [hwinbin], EM_SETLIMITTEXT, 32, 0

        invoke  GetWindowLong, [hwindec], GWL_WNDPROC
        mov     [hwindec_proc], eax
        invoke  SetWindowLong, [hwindec], GWL_WNDPROC, WinConverterNewProc
        invoke  GetWindowLong, [hwinbin], GWL_WNDPROC
        mov     [hwinbin_proc], eax
        invoke  SetWindowLong, [hwinbin], GWL_WNDPROC, WinConverterNewProc
        invoke  GetWindowLong, [hwinhex], GWL_WNDPROC
        mov     [hwinhex_proc], eax
        invoke  SetWindowLong, [hwinhex], GWL_WNDPROC, WinConverterNewProc
        invoke  GetWindowLong, [hwinexp], GWL_WNDPROC
        mov     [hwinexp_proc], eax
        invoke  SetWindowLong, [hwinexp], GWL_WNDPROC, WinConverterNewProc

    mov     eax, dword TRUE
    jmp     processed
close:
    invoke  EndDialog,[hWnd],0 ;We only get here when closing
processed:
    pop     edi ebx            ;Put values back
    ret
endp

proc   WinConverterNewProc hWnd,msg,wParam,lParam
        mov     ecx, [hWnd]
        cmp     [msg], WM_KEYDOWN
        je      .wmkeydown
        cmp     [msg], WM_CHAR
        je      .wmchar

      .oldcall:
        cmp     ecx, [hwindec]
        jne     .cnt1
        mov     ebx, [hwindec_proc]
        jmp     .cnt_ok
      .cnt1:
        cmp     ecx, [hwinbin]
        jne     .cnt2
        mov     ebx, [hwinbin_proc]
        jmp     .cnt_ok
      .cnt2:
        cmp     ecx, [hwinhex]
        jne     .cnt3
        mov     ebx, [hwinhex_proc]
        jmp     .cnt_ok
      .cnt3:
        cmp     ecx, [hwinexp]
        jne     .cnt4
        mov     ebx, [hwinexp_proc]
        jmp     .cnt_ok
      .cnt4:

      .cnt_ok:
        invoke  CallWindowProc, ebx, [hWnd], [msg], [wParam], [lParam]
        ret

  .wmkeydown:
        cmp     [wParam], VK_F1
        je      .tasto_F1
        cmp     [wParam], VK_RETURN
        je      .tasto_escape
;        cmp     [wParam], VK_ESCAPE
;        je      .tasto_escape
        stdcall _Strs, [wParam], __Hex, Buff1
        invoke  MessageBox, NULL, Buff1, AppName, NULL

        jmp    .oldcall

      .tasto_F1:
        invoke  MessageBox, NULL, AppName, AppName, NULL
        jmp    .oldcall

      .tasto_escape:
        invoke  MessageBox, NULL, AppName, AppName, NULL
        invoke  SetFocus, [hAsmEditwin]
        jmp    .oldcall
  .wmchar:
        invoke  MessageBox, NULL, AppName, AppName, NULL

        cmp     [wParam], VK_ESCAPE
        je      .tasto_escape
        jmp    .oldcall
    


and here the dialog

Code:
  dialog WinConterdterD,'WinConterter', 560,234,240,80,WS_CAPTION+WS_POPUP+DS_MODALFRAME+WS_EX_TOOLWINDOW ;WS_SYSMENU+
       dialogitem 'STATIC',     'Dec:',         ID_WINDECstatic,0,7,22,12,WS_VISIBLE+ES_CENTER
       dialogitem 'STATIC',     'Bin:',         ID_WINBINstatic,0,22,22,12,WS_VISIBLE+ES_CENTER
       dialogitem 'STATIC',     'Hex:',         ID_WINHEXstatic,0,37,22,12,WS_VISIBLE+ES_CENTER
       dialogitem 'STATIC',     'Exp:',         ID_WINEXPstatic,0,52,22,12,WS_VISIBLE+ES_CENTER
       dialogitem 'EDIT',       '',             ID_WINDEC,22,5,178,12,WS_VISIBLE+WS_BORDER+WS_TABSTOP+ES_AUTOHSCROLL+ES_UPPERCASE
       dialogitem 'EDIT',       '',             ID_WINBIN,22,20,178,12,WS_VISIBLE+WS_BORDER+WS_TABSTOP+ES_AUTOHSCROLL+ES_UPPERCASE
       dialogitem 'EDIT',       '',             ID_WINHEX,22,35,178,12,WS_VISIBLE+WS_BORDER+WS_TABSTOP+ES_AUTOHSCROLL+ES_UPPERCASE
       dialogitem 'EDIT',       '',             ID_WINEXP,22,52,206,12,WS_VISIBLE+WS_BORDER+WS_TABSTOP+ES_AUTOHSCROLL+ES_UPPERCASE
  enddialog
    
Post 09 Feb 2006, 06:48
View user's profile Send private message Reply with quote
Crukko



Joined: 26 Nov 2005
Posts: 118
Crukko 09 Feb 2006, 06:55
shoorick: with subclass you can get msg of a window before the winproc process it Wink so you can do something you want and then let the window process msg normally.
For code of subclass do a search in the forum, you'll find an example.....if you still need help, ask me again, ok? Wink
BtW: you can also find another way to do subclassing in the code I put in this post Wink
Post 09 Feb 2006, 06:55
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 09 Feb 2006, 08:37
ok Wink btw, i already found something there: http://board.flatassembler.net/topic.php?t=4359

also, you have note that dialog window do not send all messages to its children, for this you can read about WM_GETDLGCODE message Wink

regards!
Post 09 Feb 2006, 08:37
View user's profile Send private message Visit poster's website Reply with quote
Crukko



Joined: 26 Nov 2005
Posts: 118
Crukko 09 Feb 2006, 08:48
Great!
Do you have an example of using that msg ????
Post 09 Feb 2006, 08:48
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 09 Feb 2006, 09:37
Post 09 Feb 2006, 09:37
View user's profile Send private message Visit poster's website Reply with quote
Crukko



Joined: 26 Nov 2005
Posts: 118
Crukko 09 Feb 2006, 09:58
can you post here the file, pls?
Post 09 Feb 2006, 09:58
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 09 Feb 2006, 10:08
ok Wink but it was written not by me!

_________________
UNICODE forever!
Post 09 Feb 2006, 10:08
View user's profile Send private message Visit poster's website Reply with quote
Crukko



Joined: 26 Nov 2005
Posts: 118
Crukko 09 Feb 2006, 10:20
ok, don't worry Wink thx 1000

but there is a problem: using WM_GETDLGCODE now the tab key doesn't work! if I want to change the focus I have to write more code than process another key for my purpose Sad
Post 09 Feb 2006, 10:20
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 09 Feb 2006, 10:41
i just know about this msg, but did not use it in own code. read more about codes returned on WM_GETDLGCODE : try another combinations instead of DLGC_WANTALLKEYS (eg.: DLGC_DEFPUSHBUTTON etc.)
Post 09 Feb 2006, 10:41
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 06 Mar 2006, 14:59
here is test application: it will catch in upper editor pressing of enter, ctrl+enter, escape, arrows, tab, shift+tab, pgdn/pgup, ctrl+home and ctrl+end, and shift+del, and show matching number in lower editor.


Description:
Download
Filename: test_lvk.2.zip
Filesize: 4.32 KB
Downloaded: 323 Time(s)


_________________
UNICODE forever!
Post 06 Mar 2006, 14:59
View user's profile Send private message Visit poster's website 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.