| 发表于:2007-04-01 18:02:113楼 得分:0 |
给你看看源代码: public class frmlogin : system.windows.forms.form { private system.windows.forms.label lblselectoption; private system.windows.forms.combobox cbooption; private system.windows.forms.notifyicon ntibooks; private system.windows.forms.contextmenu cmumouseright; private system.windows.forms.menuitem mnuexit; private system.componentmodel.icontainer components; public frmlogin() { initializecomponent(); } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void dispose( bool disposing ) { if( disposing ) { if (components != null) { components.dispose(); } } base.dispose( disposing ); } #region windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void initializecomponent() { this.components = new system.componentmodel.container(); system.resources.resourcemanager resources = new system.resources.resourcemanager(typeof(frmlogin)); this.lblselectoption = new system.windows.forms.label(); this.cbooption = new system.windows.forms.combobox(); this.ntibooks = new system.windows.forms.notifyicon(this.components); this.cmumouseright = new system.windows.forms.contextmenu(); this.mnuexit = new system.windows.forms.menuitem(); this.suspendlayout(); // // lblselectoption // this.lblselectoption.location = new system.drawing.point(43, 51); this.lblselectoption.name = "lblselectoption "; this.lblselectoption.size = new system.drawing.size(80, 23); this.lblselectoption.tabindex = 0; this.lblselectoption.text = "选择选项: "; this.lblselectoption.textalign = system.drawing.contentalignment.middleleft; // // cbooption // this.cbooption.dropdownstyle = system.windows.forms.comboboxstyle.dropdownlist; this.cbooption.items.addrange(new object[] { "选择1 ", "选择2 "}); this.cbooption.location = new system.drawing.point(112, 51); this.cbooption.name = "cbooption "; this.cbooption.size = new system.drawing.size(128, 20); this.cbooption.tabindex = 1; this.cbooption.selectedindexchanged += new system.eventhandler(this.cbooption_selectedindexchanged); // // ntibooks // this.ntibooks.contextmenu = this.cmumouseright; this.ntibooks.icon = ((system.drawing.icon)(resources.getobject( "ntibooks.icon "))); this.ntibooks.text = "notifyicon测试 "; this.ntibooks.visible = true; this.ntibooks.mousedown += new system.windows.forms.mouseeventhandler(this.ntibooks_mousedown); // // cmumouseright // this.cmumouseright.menuitems.addrange(new system.windows.forms.menuitem[] { this.mnuexit}); // // mnuexit // this.mnuexit.index = 0; this.mnuexit.text = "退出(&e) "; this.mnuexit.click += new system.eventhandler(this.exit); // // frmlogin // this.autoscalebasesize = new system.drawing.size(6, 14); this.clientsize = new system.drawing.size(294, 125); this.controls.add(this.cbooption); this.controls.add(this.lblselectoption); this.formborderstyle = system.windows.forms.formborderstyle.fixeddialog; this.icon = ((system.drawing.icon)(resources.getobject( "$this.icon "))); this.maximizebox = false; this.name = "frmlogin "; this.startposition = system.windows.forms.formstartposition.centerscreen; this.text = "notifyicon测试 "; this.resumelayout(false); } #endregion /// <summary> /// 应用程序的主入口点。 /// </summary> [stathread] static void main() { application.run(new frmlogin()); } private void cbooption_selectedindexchanged(object sender, system.eventargs e) { switch(cbooption.selectedindex) { case 0: this.visible = false; messagebox.show( "测试用对话框1 "); break; case 1: this.visible = false; messagebox.show( "测试用对话框2 "); break; default: break; } } private void exit(object sender, system.eventargs e) { application.exit(); } private void ntibooks_mousedown(object sender, system.windows.forms.mouseeventargs e) { if (e.button==mousebuttons.left & e.clicks == 2) { if (!this.visible) { this.visible = true; } if (this.windowstate == formwindowstate.minimized) { this.windowstate = formwindowstate.normal; } this.activate(); } } } | | |
|