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

  • Home
  • SEARCH
  • 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 4087126
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:48:56+00:00 2026-05-20T18:48:56+00:00

I have wrote a frame application, it’s a windows form app as parent form.When

  • 0

I have wrote a frame application, it’s a windows form app as parent form.When it starts, it will find dlls in /modules and load them as extensions. And when I click the menuItem in the parent form, the specific dll will work.If the dll is a Form app, it will show.But when i try to use shortcuts(only build-ins,eg : CTRL-C…) in the childForm ,the hotkeys does not work. Anyone kindly tell me why and how can i fix the issue? Here’s my code:

//parent.exe--ModuleEntrance.cs
public abstract class ModuleEntrance {
  public abstract string[] GetMenuNames();
  public abstract string[] GetMenuItemNames();
  public abstract EventHandler[] GetEventHandlers();
}
//parent.exe--ParentForm.cs
public partial class MDIParent : Form {
  public MDIParent() { //CTOR
    InitializeComponent();
    ModuleEntrance oneEntrance;
    string oneMenuName, oneMenuItemName;
    ToolStripMenuItem theMenu, theMenuItem;
    for(){ //iterate dlls in /modules, if it implement ModuleEntrance, load it. 
          //And 1)load menu&menuItem.  
          //2) connect handler to menuItem.click through 
        //<code:theMenuItem.Click += new EventHandler(oneEntrance.GetEventHandlers()[i]);>
    }
}

//--------------
//child.dll-- EntranceImp.cs  //implement AC
public class EntranceImp : ModuleEntrance {
  public override string[] GetMenuNames() {
    return new string[] { "MENU"};
  }
  public override string[] GetMenuItemNames() {
    return new string[] { "OpenChildForm"};
  }
  public override EventHandler[] GetEventHandlers() {
    return new EventHandler[]{
      (EventHandler)delegate(object sender, EventArgs e) { //Anonymous method
        childForm form = new childForm();
        //find MDIparent and connect them
        ToolStripMenuItem mi = (ToolStripMenuItem)sender;
        form.MdiParent = (Form)(mi.OwnerItem.Owner.Parent);  //It works!
        form.Show();
      }
    };
  }
}
//child.dll--childForm.dll
//...
  • 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-20T18:48:57+00:00Added an answer on May 20, 2026 at 6:48 pm

    The child form has to notify the parent form about the key-down events somehow.

    A way to do this is to have the child form expose key-down events that the parent form can listen to. Remember to remove the parent event handlers every time that you change child form, or you’ll end up with a memory leak since objects are not garbage collected until you release all references to them, including event handlers.

    class Parent
    {
        KeyEventHandler KeyDownHandler;
    
        public Parent()
        {
            KeyDownHandler = new KeyEventHandler(form_TextBoxKeyDown);
        }
    
        void SetChildForm(Child form)
        {
            form.TextBoxKeyDown += KeyDownHandler;
        }
    
        void RemoveChildForm(Child form)
        {
            form.TextBoxKeyDown -= KeyDownHandler;
        }
    
        void form_TextBoxKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Control)
            {
                switch (e.KeyCode)
                {
                    case Keys.C:
    
                        break;
                    case Keys.X:
    
                        break;
                    case Keys.V:
    
                        break;
                }
            }
        }
    }
    
    class Child
    {
        TextBox txtBox;
    
        public event KeyEventHandler TextBoxKeyDown;
    
        internal Child()
        {
            txtBox.KeyDown += new KeyEventHandler(txtBox_KeyDown);
        }
    
        void txtBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (TextBoxKeyDown != null)
                TextBoxKeyDown(sender, e);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Windows Forms application that I wrote that does some monitoring of
I have a Perl application someone else wrote and I'm trying to make it
I have several small open-source projects that I wrote. All my attempts to find
I have a JTable in a swing application. I wrote a quick and dirty
I have a bowling web application that allows pretty detailed frame-by-frame information entry. One
So all of the pages on my web application have URIs of the form
I have this Array i wrote a function MostFreq that takes an array of
I wrote this code I have these errors Cannot implicitly convert type x.Program.TreeNode' to
I have a Python script I recently wrote that I call using the command
I have a macro that I wrote to just help me with my unit

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.