C # message Workflow

Source: Internet
Author: User

C #The message in is retrieved by the Application class from the Application message queue and distributed to the corresponding form of the message. The first response function of the form object is protected override void WndProc (ref System. windows. forms. message e) method.
It then calls the default message response function (such as OnMouseDown) based on the message type, the default response function then according to the event field of the object (such as this. the function pointer list in MouseDown. It calls the user-added response functions (such as Form1_MouseDown1 and Form1_MouseDown2), and the call sequence is the same as the user-added sequence.
.

According to this process, I have developed an imitation program. If there are any shortcomings, please provide more comprehensive 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 ;}

}

}

 

// Mimic the Application class

Class M_Application

{

 

Public static void Run (M_Form form)

{

Bool finished = false;

Do

{

Console. WriteLine ("Input a char ");

String response = Console. ReadLine ();

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

Switch (responseChar)

{

Case X:

Finished = true;

Break;

Default:

// Obtain the key information Parameters

KeyEventArgs keyEventArgs = new KeyEventArgs (responseChar );

& N

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.