Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


Setting hotkey of textbox filter_list
Author
Message
Setting hotkey of textbox #1
how can set keys Through textbox Like This
Code:
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
        If keyData = (TextBox1.Text) Then
            Label1.Text = TextBox1.Text
        End If
    End Function
it is work when add code
Code:
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
        If keyData = (Keys.A) Then
            Label1.Text = TextBox1.Text
        End If
    End Function
but if i need change it from application i will need to write name button in textbox
so how i can do this any one have a idea !

-Thread title changed by Moderator

Reply

RE: Any One can help me here ! #2
I have no idea what you just said there^
[Image: rytwG00.png]
Redcat Revolution!

Reply

RE: Any One can help me here ! #3
It's precisely 10:57pm EST here Stateside.
As such, that's roughly 1 hour before my brain goes into Brain Dead Mode as is customary at said time.
Thus will I translate the above for you on the morrow...or maybe the morrow after the morrow.

Reply

RE: Any One can help me here ! #4
(03-17-2013, 11:12 PM)Coder-san Wrote: I have no idea what you just said there^
ok
 i mean how can set hot key of textbox
(03-18-2013, 03:59 AM)Linuxephus Wrote: It's precisely 10:57pm EST here Stateside.
As such, that's roughly 1 hour before my brain goes into Brain Dead Mode as is customary at said time.
Thus will I translate the above for you on the morrow...or maybe the morrow after the morrow.
Smile :angel:

Reply

RE: Setting hotkey of textbox #5
Use the PreviewKeyDown event, because it happens beforehand...

C#, but easily, you should be able to see what i'm doing with this:
Code:
void Form1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
    if (e.KeyData == Keys.A)
    {
        // Do something?
    }
}

http://msdn.microsoft.com/en-us/library/...ydown.aspx
MSDN Wrote:Occurs before the KeyDown event when a key is pressed while focus is on this control.

Read the Remarks as it is important, and look at the example code with the VB tab selected to view the VB.NET version.

If you want to use a Key event, there's KeyDown and KeyUp as well, but I would highly recommend KeyUp over the KeyDown, and for a few reasons.
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

RE: Setting hotkey of textbox #6
orrrrr....
Code:
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Integer) As Short
Code:
Public Function GetKeyState(ByVal key As Integer) As Boolean
        Dim s As Short
        s = GetAsyncKeyState(key)
        If s = 0 Then Return False
        Return True
    End Function
Code:
If GetKeyState(Keys.*) = True Then
'put this if statement in a thread to run through to keep a check on it.
End If

This way it checks through out the whole time while running the program for a hotkey.
[username], need some help?, PM me.
[Image: kjKks6Y.png]

Reply

RE: Setting hotkey of textbox #7
(03-20-2013, 01:22 AM)RA1N Wrote: orrrrr....
Code:
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Integer) As Short
Code:
Public Function GetKeyState(ByVal key As Integer) As Boolean
        Dim s As Short
        s = GetAsyncKeyState(key)
        If s = 0 Then Return False
        Return True
    End Function
Code:
If GetKeyState(Keys.*) = True Then
'put this if statement in a thread to run through to keep a check on it.
End If

This way it checks through out the whole time while running the program for a hotkey.

Perhaps, but you have to call it multiple times to make sure that it hits the time a user presses a key because it's not based on events. He wanted a hotkey for specifically a textbox as I read it. If you wanted a global system-wide hotkey, you could do it this way, but it is a very poor way, and it uses a lot of resources because it has to be called constantly.

There's much better ways, even avoiding this, and a keyboard hook, but a keyboard hook is the ultimate way in my opinion, because you don't have to register and unregister a specific hotkey that may already be taken by something else.
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply







Users browsing this thread: 1 Guest(s)