How do I catch a VK_TAB key in my TEdit control and not let it lose the focus?

前端 未结 3 838
太阳男子
太阳男子 2021-01-06 07:24

In my TEdit field I have text in the form ...

My idea is:

When a user enters the control using TAB from

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-06 07:43

    1. you can catch a Tab press on a KeyDown event. (Happens before the KeyPress Event)
    2. in a KeyDown event you can set the Key to #0

    Oh and in a Key Press event you can set the Key to 0

    EDIT The following is a call stack capturing a KeyDown event for a TAB key

    Form1.TForm1.GetTab((45061, 9, 0, 983041, 0))
    :0101f444 TForm1.GetTab
    :004dca20 TWinControl.WndProc + $500
    :004ef754 TCustomForm.WndProc + $558
    :004d86b3 TControl.Perform + $27
    :004ded6a TWinControl.CNKeyDown + $D6
    :004dca20 TWinControl.WndProc + $500
    :004dc147 TWinControl.MainWndProc + $2F
    :004306ea StdWndProc + $16
    :7e418734 USER32.GetDC + 0x6d
    :7e418816 ; C:\WINDOWS\system32\USER32.dll
    :7e41b4c0 ; C:\WINDOWS\system32\USER32.dll
    :7e41b50c ; C:\WINDOWS\system32\USER32.dll
    :7c90eae3 ntdll.KiUserCallbackDispatcher + 0x13
    :7e42f3cc USER32.SendMessageA + 0x49
    

    As you can see it doesn go through KeyDown as normal keys do but instead calls BroadCast to send the message out....

    So you'll need a message catcher

    Procedure GetTab( var Message: TCMDialogkey ); message CM_DIALOGKEY;
    

    to catch it.

提交回复
热议问题