C# The message in is Application Class from the application message queue , And then distribute it to the corresponding form of the message , The first response function of a form object is protected override void WndProc(ref System.Windows.Forms.Message e) Method .
     It calls the default message response function according to the type of message ( Such as OnMouseDown), The default response function then depends on the event field of the object ( Such as this.MouseDown ) List of function pointers in , Call the response function added by the user ( Such as Form1_MouseDown1 and Form1_MouseDown2), And the calling order is the same as the user adding order

According to this process , I made an imitation program , If there are some deficiencies, please provide more perfect supplements .

using System;

// Create a delegate , Return type void, Two parameters

public delegate void KeyDownEventHandler(object sender, KeyEventArgs e);

// Data parameter class

class KeyEventArgs : EventArgs


private char keyChar;

public KeyEventArgs(char keyChar)

: base()


this.keyChar = keyChar;


public char KeyChar


get { return keyChar; }



// imitation Application class

class M_Application


public static void Run(M_Form form)


bool finished = false;



Console.WriteLine("Input a char");

string response = Console.ReadLine();

char responseChar = (response == "") ? ' ' : char.ToUpper(response[0]);

switch (responseChar)


case 'X':

finished = true;



// Get the parameters of the key information

KeyEventArgs keyEventArgs = new KeyEventArgs(responseChar);

// Send a message to the form




} while (!finished);



// Imitate the form class

class M_Form


// Defining events

public event KeyDownEventHandler KeyDown;

public M_Form()


this.KeyDown += new KeyDownEventHandler(this.M_Form_KeyDown);


// Event handler

private void M_Form_KeyDown(object sender, KeyEventArgs e)


Console.WriteLine("Capture key:{0}", e.KeyChar);


// Form handling functions

public void WndProc(KeyEventArgs e)


KeyDown(this, e);



// Main program running

class MainEntryPoint


static void Main()


M_Application.Run(new M_Form());



C# More articles on the workflow of messages in

  1. Scrapy The core workflow of and POST request

    Five core components workflow post Request to send recursive crawl Five core components workflow engine (Scrapy) Data flow processing for the whole system , Trigger transaction ( Framework core ) Scheduler (Scheduler) To accept requests from the engine , ...

  2. analysis Android in View workflow

    Based on the analysis of View The workflow of , We need to analyze a very important class first ,MeasureSpec. This class is in the View The measurement of (Measure) It will be used in the process . MeasureSpec MeasureSpec yes View The static interior of ...

  3. Kafka( Distributed Publishing - Subscribe to the messaging system ) Workflow description

    Kafka System architecture Apache Kafka It's distributed publishing - Subscribe to the messaging system . It was originally made by LinkedIn Companies to develop , Then become Apache Part of the project .Kafka It's fast . Extensible . Design is inherently distributed , Partitioned and ...

  4. Java Workflow of dynamic agent

    When it comes to dynamic proxies, you think of interfaces , Because the interface is a specification , The dynamic proxy object can clearly know its implementation class through the interface ( Proxied object ) What kind of ( That is, what are the methods ).Now, But let's start writing an example to understand the whole process of dynamic proxy : First of all ...

  5. RDIFramework.NET ━ .NET Framework of rapid information system development ━ Introduction to workflow components

    RDIFramework.NET ━ .NET Framework of rapid information system development Introduction to workflow components RDIFramework.NET, be based on .NET Rapid information system development . Integration Framework , Best for users and developers .Net The frame Department ...

  6. RDIFramework.NET ━ .NET Framework of rapid information system development ━ Workflow components Web Business platform

    RDIFramework.NET ━ .NET Framework of rapid information system development   Workflow components Web Business platform Take the first two : RDIFramework.NET ━ .NET Framework of rapid information system development ━ Workflow components ...

  7. RDIFramework.NET ━ .NET Framework of rapid information system development ━ Workflow components WinForm Business platform

    RDIFramework.NET ━ .NET Framework of rapid information system development Workflow components WinForm Business platform Next chapter : RDIFramework.NET ━ .NET Framework of rapid information system development ━ Workflow group ...

  8. cocos Resource workflow

    In front of the word This article will introduce in detail cocos  Resource workflow in summary [ Synchronicity ] The resources in the explorer are synchronized with the project resources folder seen in the file manager of the operating system The movement of resources in resource manager . Rename and delete , Will be directly in use ...

  9. Storm What's in English -acker,acker Workflow Introduction

    summary We know storm An important feature is that it ensures that every message you send will be processed completely , Complete processing means : One tuple Being dealt with completely means : This tuple And by this tuple All the resulting tupl ...

Random recommendation

  1. Replace variable & and &&

    Substitution variables can be considered as placeholders One . Single & Symbol replacement SQL The most basic part of a sentence is . The most common form of element substitution is a single & Symbol replacement .& A symbol is a symbol used to specify a replacement variable in a statement . When executing a statement ,Oracle Server ...

  2. ADF_ADF Faces series 1_ Use JSF Based on Development Ajax The user interface :ADF Faces Introduction to rich client components (Part1)

    2013-05-01 Created By BaoXinjian

  3. Realization JavaScript There are three ways of inheritance in English

    stay JavaScript in , There are three ways to realize prototype chain inheritance Use apply.call Method Inheritance between object instances .     One . Prototype chain inheritance In the aspect of prototype chain inheritance ,JavaScript And java.c# And so on ...

  4. Ubuntu 16.04 On Docker Use notes

    One .Docker Hub Use Docker Hub yes Docker Officially maintained warehouse , It already contains a lot of images , Generally, our needs can be solved by searching the official warehouse directly . In the official public warehouse, we can mirror without logging in ...

  5. ZOJ-2965

    Accurately Say "CocaCola"! Time Limit: 2 Seconds      Memory Limit: 65536 KB In a party he ...

  6. es6 Summarize knowledge points

    1. let  and const Valid only in code blocks   {}   js Block level scope . const Defined objects can change their properties const a =[], b={} ; a.push(1); b.a=1; / ...

  7. MySQL List stored procedures

    MySQL  List stored procedures Here's how to list MySQL All stored procedures in the database , And display some very useful statements of stored procedure source code . MySQL Provides some useful statements for , You can manage stored procedures more effectively . These statements include listing ...

  8. MVC Of SignalR Example

    # SignalR Study ASP.NET SignalR Is for .NET Developers provide instant messaging Web Class library of application . im Web The service is that the server automatically pushes the content to the connected client , Instead of the server waiting for the client to initiate a ...

  9. 【LeetCode】502. IPO

    subject hypothesis LeetCode It's about to start IPO. In order to sell shares to venture capital companies at a higher price ,LeetCode Hope that in IPO Some projects have been carried out to increase its capital . Due to limited resources , It can only be found in IPO Most completed before ...

  10. [Scikit-learn] *Dynamic Bayesian Network - Partical Filter

    Some of the knowledge involved : Robot self positioning Sequential Importance Sampling Ref: http://scipy-cookbook.readthedocs.io/items/Par ...