现在刚学习C#智能设备程序开发,发现在WIn32平台上对于Form类,可以通过重写DefWndProc来实现自定义事件的处理,但是在wince平台上则无法实现,总提示无法重写DefWndProc方法。
恳请,高手指点一下,谢谢!
恳请,高手指点一下,谢谢!
解决方案 »
- 字符串和汉字互转 马上给分
- Graphics g=e.Graphics 和Graphics g=this.CreateGraphics 区别?
- 急!!读取文本文件的问题,在线等!!
- 还是关于webBrowser控件的问题,这次只要解决,分全给他
- 呵呵,大家好,我想请问在C#中一张浮动图片它的背景颜色不断的变化,需要加哪些代码呢?赶快来拿分把!
- 困扰我们的项目设计
- 急求解答方法 站点地图中 转义字符
- 关于C#运行库
- 为什么我的TEXTBOX没有SETFOCUS方法?
- 请教各位:c#默认继承级别为什么这么奇怪
- 问一个关于ShowDialog()打开的子窗体如何获取父窗体名字的问题
- 跨编译环境调用事件
using System.Windows.Forms;
using Microsoft.WindowsCE.Forms;namespace MsgWindow
{
public class MessageWindowForm : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mainMenu1; // Create an instance of MsgWindow, a derived MessageWindow class.
MsgWindow MsgWin; public MessageWindowForm()
{ InitializeComponent(); // Create the message window using this form for its constructor.
this.MsgWin = new MsgWindow(this); }
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.Menu = this.mainMenu1;
this.Text = "Message Window Test"; }
#endregion static void Main()
{
Application.Run(new MessageWindowForm());
} // Process taps to generate messages
// with the WParam and LParam parameters
// using the X and Y mouse coordinates.
protected override void OnMouseMove(MouseEventArgs e)
{
Message msg = Message.Create(MsgWin.Hwnd,
MsgWindow.WM_CUSTOMMSG,
(IntPtr)e.X,
(IntPtr)e.Y);
MessageWindow.SendMessage(ref msg);
base.OnMouseMove(e);
} // This callback method responds to the Windows-based message.
public void RespondToMessage(int x, int y)
{
this.Text = "X = " + x.ToString() + ", Y= " + y.ToString();
}
} // Derive MessageWindow to respond to
// Windows messages and to notify the
// form when they are received.
public class MsgWindow : MessageWindow
{
// Assign integers to messages.
// Note that custom Window messages start at WM_USER = 0x400.
public const int WM_CUSTOMMSG = 0x0400;
// Create an instance of the form.
private MessageWindowForm msgform; // Save a reference to the form so it can
// be notified when messages are received.
public MsgWindow(MessageWindowForm msgform)
{
this.msgform = msgform;
} // Override the default WndProc behavior to examine messages.
protected override void WndProc(ref Message msg)
{
switch(msg.Msg)
{
// If message is of interest, invoke the method on the form that
// functions as a callback to perform actions in response to the message.
case WM_CUSTOMMSG:
this.msgform.RespondToMessage((int)msg.WParam, (int)msg.LParam);
break;
}
// Call the base WndProc method
// to process any messages not handled.
base.WndProc(ref msg);
}
}
}