Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Ripping Hair out: Get(Async)KeyState API Help PLEASE!


Ripping Hair out: Get(Async)KeyState API Help PLEASE!

Author
Message
rj_budz
rj_budz
Forum God
Forum God (333 reputation)Forum God (333 reputation)Forum God (333 reputation)Forum God (333 reputation)Forum God (333 reputation)Forum God (333 reputation)Forum God (333 reputation)Forum God (333 reputation)Forum God (333 reputation)

Group: Forum Members
Posts: 1, Visits: 1

I've adopted legacy code (yech!) that requires a lot of debugging & enhancement. 

This is an MS Access "application" so I'm using VBA to do all this.

I thought it'd be great if I could have users click a control, form, whatever, with the right mouse button and have a bug-report form pop up allowing him/her to enter data about the item in question.

I accomplished this by using GetAsyncKeyState(VB_RBUTTON) in a timer sub.  Works great.  EXCEPT for one thing, and you probably already know what that is.

Because GetAsyncKeyState is an API, my pop-up dialog will show itself when the right button is clicked NO MATTER WHAT APPLICATION the user has active.  So if he/she has my app running, then goes to Internet Explorer and right clicks, well, you know.

Obviously this is NOT what I want to happen. I do not want bug reports for Internet Explorer. I only want my bug form to show up if my app has focus.

I tried the Screen object to determine what has focus, but this doesn't work because at the time I query this object, Access will always be the active app, since this is when the code is executing from.

Variations on GetKeyState don't help either.

Suggestions, please?  At least a point in the right direction?

Thanks.  I'm gonna go call Hair Club now....


kwandobe
kwandobe
Forum God
Forum God (5.8K reputation)Forum God (5.8K reputation)Forum God (5.8K reputation)Forum God (5.8K reputation)Forum God (5.8K reputation)Forum God (5.8K reputation)Forum God (5.8K reputation)Forum God (5.8K reputation)Forum God (5.8K reputation)

Group: Forum Members
Posts: 22, Visits: 4
In your code before where it loops looking for the key to be pushed you need to add something like:

Public NoFocus as Boolean

If NoFocus Then Exit Sub

and in the forms GotFocus you need to put

NoFocus = False

in the forms LostFocus you need to put

NoFocus = True

-kwandobe


GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search