wince中处理消息

来源:互联网 发布:新城吾悦广场网络摇号 编辑:程序博客网 时间:2024/06/06 02:16

在网上查了资料,wince中,c#的from不能直接处理消息,但是可以通过重载MessageWindow基类的WinProc方法,来处理收到的消息。

  下面的代码,是在扫描条码的时候用到的,还有点问题。

  激光头扫描条码成功后,会发出WM_SCAN消息,窗体可以通过这个消息来获取条码,在CGC600Msg构造函数中指定获取消息的窗体,在窗体中定义 gcMsg =  new CGC600Msg(this);就可以扫描条码,CGC600Msg会获取到这个消息。但是没搞清楚如何获取条码,以后有机会再研究一下。

 

view plaincopy to clipboardprint?
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Text;  
  4. using Microsoft.WindowsCE.Forms;  
  5. using System.Windows.Forms;  
  6.   
  7. namespace GC600Test  
  8. {  
  9.     public class CGC600Msg: MessageWindow  
  10.     {  
  11.         private System.Windows.Forms.Form msgForm=null;  
  12.         public const int WM_SCAN = 0x500;  
  13.   
  14.         public CGC600Msg( System.Windows.Forms.Form Form )  
  15.         {  
  16.             this.msgForm = Form;   
  17.         }  
  18.   
  19.         protected override void WndProc(ref Message m)  
  20.         {  
  21.             switch( m.Msg )  
  22.             {  
  23.                 case WM_SCAN:  
  24.                     MessageBox.Show(m.LParam.ToString());  
  25.                     MessageBox.Show(m.WParam.ToString());  
  26.                     MessageBox.Show(m.ToString());  
  27.                     break;  
  28.                 default:  
  29.                     base.WndProc(ref m);  
  30.                     break;  
  31.             }  
  32.         }  
  33.     }  
  34. }  

 

原创粉丝点击