Functions for overloading C#from
The above work requires some of the functions of the form to be overloaded so that it can be done, first of all, here is a knowledge point: How to overload the function of a form?
After building the good one WinForm project, we can find the form method that can be overloaded using the following method:
(1) Popup Object Browser
(2) Select the base type from
(3) Object Browser settings
(4) Adding overloaded methods, taking Defwndproc as an example
This is a good way to reload the function where it's needed. Because the method overloads generally do not write their own overloaded functions, to copy the function from the base class.
Intercept C#form messages
First, accept the form message, and then do some custom processing based on the intercepted message.
The first thing to do is to overload a WndProc function to receive the message and handle the message accordingly.
Then write the processing code of the message in this function:
protected override void WndProc (ref Message m) {const int wm_syscommand = 0x0112;const int sc_close = 0xf060;if (m.msg = = WM _syscommand && (int) M.wparam = = sc_close) {//this. WindowState = Formwindowstate.minimized;this. Hide (); return;} Base. WndProc (ref m);} WndProc ()
This function knowledge intercepts Wm_syscommand's sc_close message, and other messages are to be given to the message handler function Base.wndproc of the base class form.
C # intercepts form messages