Results 1 to 5 of 5

Thread: Detecting key combos problems

  1. #1

    Thread Starter
    Lively Member crazy1993's Avatar
    Join Date
    Sep 2010
    Location
    Rochester, NY
    Posts
    85

    Unhappy Detecting key combos problems

    Hey everyone,

    I am having problems while detecting key combo events in my app.

    For example, I have Alt+M set to bring up the menu bar like one does in. Windows 7. But I noticed if u press control+alt+M it still calls the menu bar. I also noticed that if focus is on a webbrowser control, none of the combos work. I have keypreview set to true by the way. The webbrowser control is really a custom class that inherrits the standard webbrowser control. Reason for the custom control is because it uses the tab control tag property. I found it in a post somewhere can remember where. I'll post the link to the info in an hour.

    Also I noticed during testing of Alt+SOME KEY that when I was holding Alt before I pressed the SOME KEY that it was calling up the code for showing/hiding the menu bar. (I originally used just Alt for the menu)

    1) how to better control key combos
    2) why does custom browser control "ignore" the keypreview being set to true?

    Sorry if this is unorganized. I posted using my iPhone (Verizon baby!!!)


    Appreciate any help you guys can give!

    --------EDIT
    Can't find the link. if u want any code (for anything) let me know ill post it.
    Last edited by crazy1993; Mar 22nd, 2011 at 09:34 PM.
    ~Dustin Schreiber
    Head Developer for TechJive Dev Team - Founder of http://www.thetechsphere.com
    Who *cares* if a laser guided 500 lb bomb is accurate to within 9 feet?
    Teamwork is essential. It gives the enemy someone else to shoot at.
    Retreating?! Hell no, we're just attacking the other direction!

    Please rate posts if you find them helpful
    <--- Over there genius

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

    Re: Detecting key combos problems

    1) Follow the Blog link in my signature and check out my post on Keyboard Events.
    2) Can't help.
    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

  3. #3

    Thread Starter
    Lively Member crazy1993's Avatar
    Join Date
    Sep 2010
    Location
    Rochester, NY
    Posts
    85

    Re: Detecting key combos problems

    Thanks for that. I did learn a lot from though, y for the code do you have if control OR Alt then Control+alt pressed? Specifically the OR and not an AND? Also to prevent the keydown event from being called repeatedly (like if I have a combo for Alt and another for Alt+D) and I am pressing Alt but before I press D? I think I would use if D then if Alt then code end if end if. For d but what do I do for the Alt+D? Sorry for not properly formatting the code, once again I am on my iPhone. I will fix it later when I am on computer.


    Second question still waiting for answer or suggestions if anyone knows.


    Thanks again.
    ~Dustin Schreiber
    Head Developer for TechJive Dev Team - Founder of http://www.thetechsphere.com
    Who *cares* if a laser guided 500 lb bomb is accurate to within 9 feet?
    Teamwork is essential. It gives the enemy someone else to shoot at.
    Retreating?! Hell no, we're just attacking the other direction!

    Please rate posts if you find them helpful
    <--- Over there genius

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

    Re: Detecting key combos problems

    That is a bitwise Or, not a logical Or. It's not testing two Boolean expressions to see whether either one or the other is set. It's checking a value to see whether specific bits are set in a value.

    All data is stored in a computer in binary form and each bit in each value can be either 0 or 1. A bitwise Or will combine two binary values into a single binary value where each bit in the result is set if and only if it is set in one OR the other of the original values. These values are just for example, but let's say that Ctrl is '00100000' in binary and Alt is '00000100'. A bitwise Or of those two values would be:
    Code:
    00100000
    00000100
    -------- OR
    00100100
    So, if Modifiers is '00100100' then it is equal to 'Ctrl Or Alt', meaning that both Ctrl and Alt were depressed and not Shift.

    Note that you can tell a bitwise And or Or and a logical And or Or because a logical operator can only be between Boolean expressions while bitwise operators can only be between numeric values. This:
    Code:
    If e.Modifiers = Keys.Control Or e.Modifiers = Keys.Alt Then
    uses a logical Or to determine whether just the Ctrl key or just the Alt key are depressed. This:
    Code:
    If e.Modifiers = (Keys.Control Or Keys.Alt) Then
    uses a bitwise Or to determine whether just the Control and Alt keys are depressed.
    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

  5. #5

    Thread Starter
    Lively Member crazy1993's Avatar
    Join Date
    Sep 2010
    Location
    Rochester, NY
    Posts
    85

    Re: Detecting key combos problems

    I just realized that i never replied to your last post! So sorry about that!

    It was very helpful! I learned a lot from it and really appreciate your time!

    Thanks again!
    ~Dustin Schreiber
    Head Developer for TechJive Dev Team - Founder of http://www.thetechsphere.com
    Who *cares* if a laser guided 500 lb bomb is accurate to within 9 feet?
    Teamwork is essential. It gives the enemy someone else to shoot at.
    Retreating?! Hell no, we're just attacking the other direction!

    Please rate posts if you find them helpful
    <--- Over there genius

Tags for this Thread

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