Wx.Net Noobie question
Andrei Pamula <[email protected]> Wed, 16 Feb 2005 15:08:48 +0100
| Newsgroups | gmane.comp.lib.wxwindows.wxnet |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I have a problem with wx.net, release 0.6.1.
I don't get an Event fired/catched on a MenuItem,
unless I use the EVT_MENU().
What did I do wrong ?
----
using System;
using System.Drawing;
using wx;
namespace SharpDilbert.WX
{
public class DatePickerFrame : Frame
{
#region "TowxNET IDS: DatePickerFrame"
public enum Cmd {
ID_ApplicationMenuBar,
ID_SettingsMenuItem,
ID_ExitMenuItem,
ID_HelpContentsMenuItem,
ID_LicenseMenuItem,
ID_AboutMenuItem,
ID_Calendar,
ID_PreviousDayButton,
ID_ShowPictureButton,
ID_NextDayButton
}
#endregion
#region "TowxNET Objects: DatePickerFrame"
private MenuBar applicationMenuBar;
private CalendarCtrl calendar;
private MenuItem settingsMenuItem;
private MenuItem exitMenuItem;
private MenuItem helpContentsMenuItem;
private MenuItem licenseMenuItem;
private MenuItem aboutMenuItem;
private BitmapButton previousDayButton;
private BitmapButton showPictureButton;
private BitmapButton nextDayButton;
#endregion
public DatePickerFrame()
: base(null, -1 , "#Dilbert Selection", wxDefaultPosition,
new Size(400,300),
wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX)
{
InitializeComponent();
helpContentsMenuItem.Enabled = false;
exitMenuItem.Click += new EventListener(OnExitClick);
//EVT_MENU((int)Cmd.ID_ExitMenuItem, new
EventListener(OnExitClick));
}
// Do not change the code between region and endregion
(incl. region and endregion)...
#region "TowxNET CTOR: DatePickerFrame"
public void InitializeComponent()
{
//common
calendar = new CalendarCtrl(this, (int)Cmd.ID_Calendar,
DateTime.Now, wxDefaultPosition, wxDefaultSize,
wx.CalendarCtrl.wxCAL_SUNDAY_FIRST|wxSUNKEN_BORDER);
previousDayButton = new BitmapButton(this,
(int)Cmd.ID_PreviousDayButton, new wx.Bitmap("pictures/back.png",
BitmapType.wxBITMAP_TYPE_ANY));
showPictureButton = new BitmapButton(this,
(int)Cmd.ID_ShowPictureButton, new wx.Bitmap("pictures/viewmag.png",
BitmapType.wxBITMAP_TYPE_ANY));
nextDayButton = new BitmapButton(this,
(int)Cmd.ID_NextDayButton, new wx.Bitmap("pictures/forward.png",
BitmapType.wxBITMAP_TYPE_ANY));
applicationMenuBar = new MenuBar();
this.MenuBar = applicationMenuBar;
Menu applicationMenu = new Menu();
settingsMenuItem = new MenuItem(applicationMenu,
(int)Cmd.ID_SettingsMenuItem, "&Settings...");
exitMenuItem = new MenuItem(applicationMenu,
(int)Cmd.ID_ExitMenuItem, "E&xit");
applicationMenu.Append(settingsMenuItem);
applicationMenu.Append(exitMenuItem);
applicationMenuBar.Append(applicationMenu,"&Application");
Menu helpMenu = new Menu();
helpContentsMenuItem = new MenuItem(helpMenu,
(int)Cmd.ID_HelpContentsMenuItem, "Contents...");
licenseMenuItem = new MenuItem(helpMenu,
(int)Cmd.ID_LicenseMenuItem, "&License...");
aboutMenuItem = new MenuItem(helpMenu,
(int)Cmd.ID_AboutMenuItem, "&About...");
helpMenu.Append(helpContentsMenuItem);
helpMenu.Append(licenseMenuItem);
helpMenu.Append(aboutMenuItem);
applicationMenuBar.Append(helpMenu,"&Help");
//Properties
previousDayButton.SetSize(previousDayButton.BestSize);
showPictureButton.SetSize(showPictureButton.BestSize);
nextDayButton.SetSize(nextDayButton.BestSize);
//Layout
BoxSizer boxsizer1 = new BoxSizer(Orientation.wxHORIZONTAL);
boxsizer1.Add(previousDayButton, 0,
wx.Alignment.wxALIGN_CENTER_VERTICAL|wx.Direction.wxALL, 5);
boxsizer1.Add(showPictureButton, 0,
wx.Alignment.wxALIGN_CENTER_VERTICAL|wx.Direction.wxALL, 5);
boxsizer1.Add(nextDayButton, 0,
wx.Alignment.wxALIGN_CENTER_VERTICAL|wx.Direction.wxALL, 5);
BoxSizer boxsizer0 = new BoxSizer(Orientation.wxVERTICAL);
boxsizer0.Add(calendar, 0,
wx.Alignment.wxALIGN_CENTER_HORIZONTAL|wx.Direction.wxALL, 5);
boxsizer0.Add(boxsizer1, 0,
wx.Alignment.wxALIGN_CENTER_HORIZONTAL|wx.Direction.wxALL, 5);
boxsizer0.Fit(this );
boxsizer0.SetSizeHints(this );
AutoLayout = true;
SetSizer(boxsizer0 );
Layout();
}
#endregion
private void OnExitClick(object aSender, Event anEvent)
{
Close(true);
}
}
}
thank you,
AndreiPamula
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click