Menus

Menus

1.     Menus provide a convenient way to group similar or related commands in one place.

Controls and Containers

1.     All Windows Forms controls inherit from the System.Windows.Forms.Control class, or simply the Control class.

2.     A class hierarchy is the set of classes from which a particular class is derived, and gives some indication of the purpose and capabilities behind the specific class.

3.     All classes in C#, even internal types such as int and char, implicitly derive from the object class. In ther .net this class is quivalent to the Object class.

4.     The MarshalByRefObject class is an object that must be marshaled by reference. Marshaling is a method of passing an item from one context so that it can be understood in another context. A typical use for marshaling is in remote procedure calls between two different machines, where each parameter of a function call must be converted into a common format(that is,marshaled) on the sending machine so that it may be interpreted on the receiving machine. In the .NET world, Windows controls are MarshalByRefObject object since they are only valid in the process that create them, and can be used outside this process only by reference.

5.     The component class is the base implementation of the Icomponent interface for objects that marshal by reference. A component is an object can exist within a container, and allows cleanup of system resources via the Dispose method. This class supports the Idisposable interface as well the Icomponent interface. Since graphical controls exist within a Form window or other container control, all Windows Forms controls ultimately derive from this class.

6.     The Windows Forms Control class is a component with a visual representation on the Windows desktop. This class provides display functionality such as position and size, keyboard and mouse input, anchor and dock support, fonts,background images, and message routing.

7.     The ButtonBase class is the base class for all buttons, including radio buttons and check box buttons in addition to the regular button class we have already seen.

8.     Controls that contain other controls are called container controls. The control class itself provides support for containers, in members such as the Controls property of the GetNextControl method.

9.     You might think that all classes with scrolling inherit from the ScrollableControl class. In fact, this class is only for objects that support automated scrolling over a contained set of objects.

10. The ContainerControl class is a control that provides focus management, providing a logical boundary for a contained set of controls. This class tracks the active control in a container even when the focus moves to an alternate container, and can manage the Tab key press for moving between the controls in the container.

The nature of menus

1.     Menus in .NET are container controls that contain menu items.

2.     The traditional menu bar, sometimes called the main menu or an anchored menu, is a set of munus shown horizontally across the top of an application.

3.     Another type of menu is a context menu, also called a pop-up menu or shortcut menu.

4.     The menu classes provided by .NET received a complete rewrite for .NET 2.o. In .NET 1.x, the menu classes were based on the Win32 menu classes, and supported via the Menu class hierarchy. The MainMenu, ContextMenu, and MenuItem classes all derived from this Menu class, supporting Win32 menus and context menus within Windows Forms applications. These classes are still supported in .NET 2.0 for compatibility and use, but are no longer the preferred mechanism for menus in most applications.

5.     The new and improved classes for menus are based on the ToolStrip and ToolStripItem classes, which are the base classes for all manner of toolbar objects and the items within them.

6.     The Form.Close method is used to exit the application.This method closes the associated Form, or the entire application if the form was the startup window for the application.

7.     The Exit method forces all message loops started by Application.Run methods to exit, and closes any forms associated with them as well.

8.     As a result, use of the Close method is mormally preferred to exit a Form rather than the Application.Exit method.

 

 

posted on 2009-10-13 16:36  韩连生  阅读(448)  评论(0)    收藏  举报

导航