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 927365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:50:26+00:00 2026-05-15T19:50:26+00:00

Issue Weird problem. We’ve got two forms: the main application window and a settings

  • 0

Issue

Weird problem. We’ve got two forms: the main application window and a settings form. The main form has its KeyPreview set to true, and a method attached to its KeyUp event. This is so that the settings window can be opened with a key shortcut (ctrl-m):

private void MyShortcuts(object sender, KeyEventArgs e)
{
    if (e.Control && e.KeyCode == Keys.M)
    {
        e.Handled = true;
        e.SuppressKeyPress = true;
        MySettings sett = new MySettings();
        sett.Show();
    }
}

Now, that bit works just fine. However, the problem is that despite setting the Handled and SuppressKeyPress properties to true, the KeyUp event is still passed on to the MySettings form. I’ve traced this to ControlNativeWindow.OnMessage receiving what seems to be a different event (its Handled and SuppressKeyPress properties are set to false), and passing that on to the form and its focused control.

Questions

  • First of all, why is the event passed on despite instructing .Net not to do so?
  • Secondly, how do I prevent the event from firing?

Any ideas will be much appreciated, I run out of them myself.

  • 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-15T19:50:27+00:00Added an answer on May 15, 2026 at 7:50 pm

    What’s happening here is that the M and the CTRL key are raising two separate KeyUp events (which is normal behavior). When you press CTRL and then M and then lift your finger off of the M key, a KeyUp event is raised, which your handler on the main form catches and uses to show the settings form. You then take your finger off of the CTRL key, which raises another KeyUp event (this time on the settings form, which is now the active form).

    On the settings form, you can just check e.Control and ignore the event if it’s true.

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

Sidebar

Ask A Question

Stats

  • Questions 500k
  • Answers 500k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you are on .NET 3.5 and can't use Parallel… May 16, 2026 at 1:52 pm
  • Editorial Team
    Editorial Team added an answer if this is a component than you won't be able… May 16, 2026 at 1:52 pm
  • Editorial Team
    Editorial Team added an answer Let's say we have a class/struct Category such that public… May 16, 2026 at 1:52 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Hello every one. I'm faced with a weird problem. My application has a simple
I have weird problem, i've placed an google ads on my page and it
Having a weird problem here. Everybody knows that if you use web.config's customErrors section
This is a weird problem I have started having recently. My team is developing
I have this weird problem with setting up cookies with PHP. Everything worked fine
I have a weird problem with HTML select box height in Firefox 2, here's
I have a weird problem, I want to add a global query using context
I have a very weird problem with PROLOG. I have used it before, but
I'm having an extremely weird problem with a PHP script of mine. I'm uploading
I'm having a weird problem on deployment while trying to use Microsoft Enterprise Library's

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.