AW: Menu Events

"Alexander Gnauck" <[email protected]> Thu, 12 Aug 2004 22:10:17 +0200
Newsgroups gmane.comp.lib.wxwindows.wxnet
Message-ID <[email protected]>
Hi Alexander,

I attached the code. I created this small form using wxGlade 0.33 and
towxnet.exe from the 0.5 binary build.

Alex

> -----Ursprüngliche Nachricht-----
> Von: [email protected] 
> [mailto:[email protected]] Im Auftrag 
> von Alexander Olk
> Gesendet: Donnerstag, 12. August 2004 21:41
> An: [email protected]
> Betreff: Re: [Wxnet-users] Menu Events
> 
> Am Do, den 12.08.2004 schrieb ALF BanCo Support um 8:33:
> > im using the binary version 0.5 on windows. When a add 
> eventhandlers 
> > to a menu item the application will exit without any error message.
> > 
> > I was trying to add the handler with the new events:
> > 
> > this.mnuFileExit.Click += new EventListener(mnuFileExit_Click);
> > 
> > private void mnuFileExit_Click(object sender, Event e) {  
> > this.Close(); }
> 
> Can you provide a little bit more code ???
> (the ctor of the Frame/Window for example...)
> 
> --
> Alexander Olk
> 
> 
> 
> -------------------------------------------------------
> SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
> 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
> Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
> http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
> _______________________________________________
> wxnet-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wxnet-users
>
frmMain.cs (text/plain, 2.3 KB)
// Generated with TowxNET, part of wx.NET, http://wxnet.sf.net
 
using System;
using System.Drawing;
using wx;

// Generated with TowxNET, part of wx.NET, http://wxnet.sf.net
 
 
namespace Newsletter
{
	//---------------------------------------------------------------------
 
	public class frmMain : Frame
	{
		// Do not change the code between region and endregion ( incl. region and endregion )...
		#region "TowxNET IDS: frame_1"
		public enum Cmd 
		{
			ID_MenuBar_menubar,
			ID_MenuItem_mnuFileExit,
			ID_MenuItem_mnuHelpAbout,
			ID_StatusBar_statusbar,
			ID_ToolBar_toolbar
		}
		#endregion
 
		//---------------------------------------------------------------------
 
		// Do not change the code between region and endregion ( incl. region and endregion )...
		#region "TowxNET Objects: frame_1"
		protected MenuBar menubar;
		protected MenuItem mnuFileExit;
		protected MenuItem mnuHelpAbout;
		protected StatusBar statusbar;
		protected ToolBar toolbar;
		#endregion
 
		//---------------------------------------------------------------------
 
		public frmMain( Window parent, int id, string title )
			: base( parent, id , "frame_1", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE )
		{
			InitializeComponent();
		}
 
		//---------------------------------------------------------------------
 
		// Do not change the code between region and endregion ( incl. region and endregion )...
		#region "TowxNET CTOR: frame_1"
		public void InitializeComponent()
		{
			//common
			toolbar = CreateToolBar( wx.ToolBar.wxTB_FLAT|wx.ToolBar.wxTB_TEXT|wx.ToolBar.wxTB_HORIZONTAL );
			toolbar.Realize();
			statusbar = CreateStatusBar( 1, wx.StatusBar.wxST_SIZEGRIP );
			menubar = new MenuBar();
			MenuBar = menubar;
			Menu mnuFile = new Menu();
			mnuFile.Append( (int)Cmd.ID_MenuItem_mnuFileExit, "Exit", "", ItemKind.wxITEM_NORMAL );
			menubar.Append( mnuFile, "File" );
			Menu mnuHelp = new Menu();
			mnuHelp.Append( (int)Cmd.ID_MenuItem_mnuHelpAbout, "About", "", ItemKind.wxITEM_NORMAL );
			menubar.Append( mnuHelp, "Help" );
 
			//Properties
			int[] statusbar_widths = { -1 };
			statusbar.SetStatusWidths( 1, statusbar_widths );
			statusbar.SetStatusText( "", 0 );
			Title = "frame_1";
 
			//Layout
			mnuFileExit.Click += new EventListener(mnuFileExit_Click);
		}
		#endregion

		private void mnuFileExit_Click(object sender, Event e)
		{

		}
	}
 
}
cMain.cs (text/plain, 612 B)
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

using wx;

namespace Newsletter
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class cMain : wx.App
	{
		
		public cMain()
		{		

		
		}

		public override bool OnInit()
		{
			frmMain frame = new frmMain(null,1,"Test");
			frame.Show(true);

			return true;
		}

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			cMain app = new cMain();
			app.Run();			

		}
	}
}