Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Hidden Action on Form

Status
Not open for further replies.

djtech2k

MIS
Jul 24, 2003
1,097
US
Sorry if this is a simple question, but what is the best way for me to add a "hidden" key combo or button in a vb.net app? Here is what I need. I have a app that different groups of people will use. It is VERY small. Depending on the group, I may or may not want them to see/access the same functions. I would describe it as an admin vs user access...

If I send it to a user, I want them to see it as it was designed, however, if I am using it I want to have something different or additional to what they see. I would like to setup some type of "easter egg" type of thing where if I so some kinda key combo or mouse combo, the app will add/change what I want.

Whats the bets way to do this and how? My best guess at the easiest way would be to add some hidden key combo that would change the form...but I am not sure how to do that or if its the bets way.

Thanks
 
djtech2k,

Well if your application is hooked to a database this is much easier. Add a field to the users table that acts as an access level indicator, when the user logs in extract that value into a global property, then you can have a constant in the application, like
Code:
Public Const ADMIN_LEVEL As Integer = 3

Then in the forms Key_Press event do something like
Code:
If Your_Global_Access_Level_Variable > ADMIN_LEVEL Then
   'Put your key combination here
End If

Senior Qik III, ASP.Net, VB.Net ,SQL Programmer

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SELECT * FROM Users WHERE clue > 0
0 Rows Returned

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Ok, well thats kinda what I need. To be specific, I would like to hit a key combo or some sort of "hidden" function that would like populate some data fields and/or show more fields.

Whats the best way and how would you suggest it? Again, my only idea would be for a keystroke, but am not sure exactly if that would do or how to handle it. I have done things like sendkeys in vbscript, but not this.
 
djtech2k,

This is really the best way to do what you're looking for. The forms Key_Press event can handle any key combination you can think of, then in that key combination you add your "hidden" function, and if you have an access level set (as described above) then the only ones who can access this are the ones with a high enough access level. This is really the best way I can think of implementing something like this.

Application Developer: VB.Net, Qik III, SQL 2000/2005

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Let's fact it, most computer users have the brain of a Spider Monkey"
~ Bill Gates ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
OK, I have a 2 button combo working, but is there any way to get a 3 button combo, like ctrl + shift + a?

Here is what I am using for the 2 button:

Code:
    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.Escape Then
'Do This
        ElseIf e.KeyCode = Keys.F1 And e.Modifiers = Keys.Control Then
'Do That
        End If
    End Sub
 
djtech2k,

To do that use
Code:
if e.KeyCode=Keys.FirstKey And e.KeyCode = Keys.SecondKey And e.KeyCode = Keys.ThirdKey Then
   'Do processing here
End If

Application Developer: VB.Net, Qik III, SQL 2000/2005

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Let's fact it, most computer users have the brain of a Spider Monkey"
~ Bill Gates ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
That did not work. Whenever I try to combine to keycodes, it doesnt work, however if I do 1 keycode and one modifier, it does work.
 
KeyDown fires when a key is pressed. If one of the required keys is pressed, then set a flag to indicated this and watch KeyUp.


That should enable you to have any number of key and modifier key combinations.


Hope this helps.

[vampire][bat]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top