Results 1 to 4 of 4

Thread: [2005] Mouse and keyboard events(help and explanation needed)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2007
    Posts
    87

    [2005] Mouse and keyboard events(help and explanation needed)

    I was wondering if it is possible to have overall mouse and keyboard events.

    I made a member system with magnetic cards for a discotheek here but there is a problem i realy want to solve.

    Cause the cardreaders are keyboard wedges so they just send out keys and presses enter when there is no more data.

    Now on my entrance screen i have just 1 focuseble object and thats a textboxt. With the standard code:
    Code:
    Private Sub Textbox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Textbox.KeyPress
            Console.WriteLine("Pressed : " & e.KeyChar)
        End Sub
    This way i can perfecly see wich char is pressed but i always need a stupid textbox in my screen with the focus on it.
    I have the same system in my 'search member' window but still then i first need to focus on the specific textbox.

    Isnt there some event that always fires when i press a key?
    And then i have exctualy the question for the mouse press events.

    I made a full screen game once when i was still @ school(still am but different now) and even then i needed a form to be able to listen to those events.

    I dont want to depend on windows controls only :@

    This is probably goeing to be API work wich i never did before.


    I hope anyone can help.


    Greets

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] Mouse and keyboard events(help and explanation needed)

    set the forms KeyPreview property to true. This will make Keyboard events filter through the forms Key events (like keypress, keydown, keyup) prior to being filtered to the actual control that has focus.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2007
    Posts
    87

    Re: [2005] Mouse and keyboard events(help and explanation needed)

    Owh thats quite easy indeed :P
    Never thought it would be that easy lol.
    Is there anything like that to do the same with mouse click events?

    Greets

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] Mouse and keyboard events(help and explanation needed)

    Quote Originally Posted by ovanwijk
    Owh thats quite easy indeed :P
    Never thought it would be that easy lol.
    Is there anything like that to do the same with mouse click events?

    Greets
    No, but you can just use a single method to handle the Click or MouseClick event for the form itself and one or more child controls.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width