Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1022603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:29:27+00:00 2026-05-16T11:29:27+00:00

I have an application using the following code to get input based on a

  • 0

I have an application using the following code to get input based on a file generated from a third party application.

    protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
    {
        const int WM_KEYDOWN = 0x100;
        const int WM_SYSKEYDOWN = 0x104;

        if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN))
        {
            switch (keyData)
            {
                case Keys.F1:
                    clicked_F1(null, null);
                    break;

                case Keys.F2:
                    clicked_F2(null, null);
                    break;

                case Keys.F3:
                    clicked_F3(null, null);
                    break;
            }
            return true;
        }
        return base.ProcessCmdKey(ref msg, keyData);
    }

Form.TopMost is set to true and this.Activate() is called during the OnShown callback. This works on most machines but occasionally the keyboard input will not be passed to my application, windows help for example will pop up if F1 is pressed.

Can anyone explain this behavior? I need to ensure my form will receive these keyboard events.

Cheers,
Richard

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:29:27+00:00Added an answer on May 16, 2026 at 11:29 am

    Having your form TopMost is not sufficient to ensure this method runs. Your form also needs to have the focus. That requires calling its Activate() method (SetForegroundWindow in the Win32 API). Which is not guaranteed to run, you cannot steal the focus away from a window that the user is actively using. Only when enough time has passed since the last input event can you grab the focus.

    Not sure what you are really trying to do, maybe you need a keyboard hook or use RegisterHotKey.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I start the NServisBus.host.exe file from my wpf application using the following code: System.Diagnostics.Process.Start(NServiceBus.Host.exe);
I am using the following code for the Share Price Application I have been
I'm developing application using backbone.js & jquery. I have following code in model: runReport:
Using linkedin-j , I have the following code in one part of my application
I have couple resource DLLs that I currently load when application starts using following
I have the following problem. I have a tabbed application implemented using a ViewPager.
I have a Spring application deployed in JBoss EAP server, using the following settings:
How can I self-sign an iPhone application using Xcode? I have done the following:
I have a following problem: I compiled my application on Linux Ubuntu 9.10 using
I have been successful with extracting text from a PDF file using GhostScript along

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.