First, minimize the window Click "X" or "Alt
F4, minimize windows, such as:
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) ... {User clicked close buttonthis.WindowState = FormWindowState.Minimized; return;} Base.WndProc (Ref M);
Second, how to make the FOREACH loop run FREACH is a ready-made statement that makes simple enumeration and processing on the elements of the collection, and the usage is shown in the following example:
Using
System;
Using
System.collections;
Namespace
Looptest
...
{Class Class1 ... {static void main (string [] args) ... {// create an arraylist of stringsrraylist array = new arraylist (); array.add ("marty"); array.add ("bill" Array.Add ("George"); // Print The value of every ItemFore (String Item in Array) ... {Console.Writeline (item);}}} You can use the foreach statement in each implementation IENUMERABLE interface collection. If you want to know more foreach usage, you can view the C # Language Specification in the .NET Framework SDK document. When compiling, the C # editor converts each Foreach area. IENUMERATOR ENUMERATOR = array.getenumerator (); try ... {string item; while (enumerator.movenext ()) ... {item = (string) enumerator.current; console.writeline (item);}} finally .. . {Idisposable d = enumerator as idisposable; if (d! = Null) d.dispose ();} This shows that in the background, Foreach's management will bring some additional code to increase system overhead.
Third, save the picture to an XML file WinForm's resource file, convert the non-text content such as PictureBox into text, which is implemented by serialization, examples: // use system.Runtime. Serialization.Formatters.Soap; Stream stream = new FileStream ( "E: //Image.xml", FileMode.Create, FileAccess.Write, FileShare.None); SoapFormatter f = new SoapFormatter (); Image img = Image.FromFile ( "E: //image.bmp"); F.Serialize (stream, img); stream.close (); four, shield Ctrl-V In WinForm's TextBox control has no way to block Ctrl-V's clipboard paste action, If you need a input box, you don't want the user to paste the contents of the clipboard, you can use the RichTextBox control, and shield the Ctrl-V key in KeyDown. ) ... {if (E.Control && E.Keycode == Keys.v) E.handled = true;} 1. Decision file or folder exists using system.IO.File, check if a file is very Simple: BOOL EXIST = System.IO.File.exists (filename); if you need to judge whether you exist, you can use system.io.directory :bool exists (foldername); Design Custom Events Using Delegate Types In C # Programming, in addition to Method and Property, any Class can have its own events (Event).