Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi!

I am working on windows application based on client server architecture using socket programming.It is language lab application . I have two console one is teacher and other is student,

I want to client(student) application such as only accept the few keys .
How I can do this?

Please help me!
Posted
Updated 24-Apr-11 20:27pm
v3
Comments
Sandeep Mewara 20-Apr-11 4:15am    
What is the reason/idea behind such a thing? Sounds fishy.
BobJanova 21-Apr-11 4:34am    
You do not need to do this. Simply making -your application- unresponsive (with a UI cue) is sufficient.

If you want to prevent the keyboard to work only in your application, take a look at WM_KEYDOWN[^].

If you want something more wide (not only for your application) then take a look at HOOKS: low-level keyboard hook[^].

I guess that with this information you'll be able to go...

HTH! :thumbsup:
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 20-Apr-11 14:40pm    
Don't encourage a crime. Also, you cannot block some key combinations. Please see the answer Kubajzz and my comment.
--SA
Joan M 20-Apr-11 14:50pm    
Of course I don't want to encourage a crime... but with the amount of information we have... who knows what that user wants to do... I've needed to use this kind of things some times... programming machine interfaces that need special requirements... And with hooks I've been able to get all the keys except Ctrl+Alt+Del... but of course this have happened years ago so probably nowadays operating systems (vista + 7) won't allow that... Anyway I understand your POV... let's hope that this CPian won't be a bad guy... Anyway if he wants to make a virus and asks those things... :rolleyes:
Sergey Alexandrovich Kryukov 20-Apr-11 15:40pm    
I never doubted you don't want it. I prefer saying "don't do it"; you're are free to choose what to answer... however, this is nothing wrong with you answer itself, I just voted 5.

Hey, I see you're an expert in CNC related programming; I just up-voted you answers on CAN. Yes, you CAN! :-)

Cheers,
--SA
Joan M 21-Apr-11 3:09am    
^^
Thank you for the 5!

Regarding CNC I've been 12 years working in my company making special machines for grinding and polishing and almost all of them have one or more robots and several CNC axis (till today up to 26 axis in one machine) and kinematical transformations...
I'm always on the setting up of the whole system, from the electronics to the software... IO's + Servoamplifiers + Servomotors + Drives + Virtual PLC + Virtual CNC with different interpolation channels + Visual C++ appliaction to give an HMI to the user + Artificial vision + Laser sensors...

It is indeed a great job that offers a lot of fun and nightmares...
Sergey Alexandrovich Kryukov 21-Apr-11 3:42am    
Good for you.
What's the motion system? I had a lot of trouble with most of them.
Unfortunately, it's too typical that an industrial-grade hardware manufacturers produce quite bad software, even illiterate; so considerable part of life is wasted in work-arounds...
--SA
You (fortunately) can't really freeze the desktop. Certain key combinations, like Alt+Tab or Ctrl+Alt+Del will always be available to the user and you should not try to overcome this behavior. However, it is possible to create a full-screen form that will not accept any mouse actions, will not be closable and will only handle the KeyDown event to deal with certain key combinations.

Anyway, why would you ever want to freeze the whole computer? I bet most users of your application will be extremely annoyed...
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 20-Apr-11 14:38pm    
You're absolutely right, my 5. This is what I would call a crime against the user.
--SA
This feels a lot like a virus :s.
For the black screen you can use a black, borderless, maximized, always-on-top form.
The keyboard, dunno.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 20-Apr-11 14:41pm    
For your information, you can do keyboard, too, but not every combination.
Kubajzz is right.
--SA
C#
public partial class BlackScreen : Form
    {
        Timer MakeTopMost = new Timer();
        public BlackScreen()
        {
            InitializeComponent();
            MakeTopMost.Enabled = true;
            MakeTopMost.Tick += new EventHandler(MakeTopMost_Tick);
            this.FormBorderStyle = FormBorderStyle.None;            
            this.StartPosition = FormStartPosition.Manual;
            this.Location = new Point(0,0);
            this.Size = Screen.PrimaryScreen.Bounds.Size;
            this.BackColor = Color.Black;            
        }

        void MakeTopMost_Tick(object sender, EventArgs e)
        {
            if (!DisableTaskManager)
            {
                DisableTaskManager = true;
            }
        }

        private bool DisableTaskManager
        {
            get { return this.TopMost; }
            set { this.TopMost = value; }
        }

        private void BlackScreen_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
 
Share this answer
 
Comments
MauryaArunKumar 26-Apr-11 1:51am    
Thanks !
charles henington 26-Apr-11 21:10pm    
if you like and it works for you vote a 5 and accept answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900