1. Form and interface design-Other Technologies

Source: Internet
Author: User

This section describes how to create and close an MDI form. during development of large projects and products, the system is often designed as an MDI interface.

047 disable the button on the window

This example mainly uses the window handler WndProc override method, which intercepts the information of clicking close window within the method, so as to disable the close button function.

Create a project. The default form is Form1. Add a MenuStrip control on the Form1 form.

Namespace _ 047_ForbidCloseButton {public partial class Form1: Form {public Form1 () {InitializeComponent ();} // after the program is loaded, When you click the close button on the Form, the method WndProc intercepts and disables information to shield 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) {return;} base. wndProc (ref m);} // when exiting the application, select the exit option under the File menu in the menu bar to private void exitToolStripMenuItem_Click (object sender, EventArgs e) {Application. exit (); // Exit the application }}}

048 implement dynamic system tray icon

This example mainly uses the Tick event of the Timer component to flash the icon in the event.

Create a project. The default form is Form1. Add a GroupBox control, two Button controls, one policyicon control, and one Timer component to the Form1 form. Set the Interval property value of the Timer component to 400.

Namespace _ 048_DynamicStockIcon {public partial class Form1: Form {public Form1 () {InitializeComponent () ;}# the variable declared by region in this program is public static bool flag = false; # endregion // when you click the "blinking" button, the private void flicker_Click (object sender, EventArgs e) {stocktimer appears. enabled = true; // start timer stocktimer} // when you click "stop", the flashing effect of the icon disappears. private void cease_Click (object sender, EventArgs e) {stocktimer. enabled = false; // disable the timer stocktimer stockIcon. icon = Properties. resources. _ 1; // set the policyicon control icon} // The blinking of the icon is through the Tick event private void stocktimer_Tick (object sender, EventArgs e) of the timer stocktimer) {if (flag = false) // when the flag value is false, {stockIcon. icon = Properties. resources. _ 1; // set the flag of the policyicon control to true; // modify the id value to true} else {stockIcon. icon = Properties. resources. _ 2; // set the flag of the policyicon control to false; // modify the flag value to false }}}}

049 Implement Bubble Prompt window

This example mainly uses the ShowBalloonTip method of the policyicon control. This method is used to continuously display the specified time for bubble prompts with the specified title, text, and icons in the taskbar.

Create a project. The default form is Form1. Add a GroupBox control, two Button controls, and one policyicon control to the Form1 form.

Namespace _ 049_AlveoliClewWindow {public partial class Form1: Form {public Form1 () {InitializeComponent ();} private void clewButton_Click (object sender, EventArgs e) {this. policyicon1.visible = true; // sets the visibility of the policyicon control to true. // this is displayed when a bubble is displayed. policyicon1.showballoontip (1000, "current time:", DateTime. now. toLocalTime (). toString (), ToolTipIcon. info);} private void closeButton_Click (object sender, EventArgs e) {this. policyicon1.visible = false; // sets the visibility of the policyicon control to false} private void policyicon1_mousemove (object sender, MouseEventArgs e) {// when the cursor moves over the policyicon control, the message this is displayed automatically. policyicon1.showballoontip (1000, "current time:", DateTime. now. toLocalTime (). toString (), ToolTipIcon. info );}}}

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.