VS.NET 2005 Beta2初体验(4)-Notification控件

VS.NET 2005 Beta2初体验(4

闲了一个五一长假,就是因为家里没有网络连接,而安装的Loopback网卡也不能用。我已经报告这个BUG了,不知道微软什么时候可以解决。大家如果在使用Beta2的过程中出现各种问题,或者有什么好的建议,都可以去MSDNFeedback中心去投诉。在MSDN网站最下边有一个反馈中心的连接,大家可以先去搜索一下有没有类似的反馈了,如果有,看他们的解决办法是什么,如果没有,记得给微软反馈,这样他们才能及时修改BUG

今天终于能写程序了,今天的主题是Notification,这是Windows CE所特有的一种消息通知方式。消息支持文本和HTML形式,当有消息出现的时候会出现一个气泡式的窗体。在以前的VS.NET 2003里,发送Notification,的主要方式是调用API或者使用OpenNETCF中的相关类。而.NET CF 2.0目前支持了托管方式的Notification

<shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"></shapetype><stroke joinstyle="miter"></stroke><formulas></formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f><lock v:ext="edit" aspectratio="t"></lock><shape id="_x0000_i1025" style="WIDTH: 380.25pt; HEIGHT: 217.5pt" type="#_x0000_t75"></shape><imagedata src="file:///C:%5CDOCUME~1%5Cmaning%5CLOCALS~1%5CTemp%5Cmsohtml1%5C01%5Cclip_image001.jpg" o:title="notify_toolbox"></imagedata>

我们首先在工具栏里找到Notification控件,并将它拖到窗体中,该控件将显示到窗体下面,和菜单控件在一起。

private void button1_Click(object sender, EventArgs e)

{

StringBuilder HTMLString = new StringBuilder();

HTMLString.Append("<html><body>");

HTMLString.Append("Submit data?");

HTMLString.Append("<form method=\'GET\' action=notify>");

HTMLString.Append("<input type='submit'>");

HTMLString.Append("<input type=button name='cmd:2' value='Cancel'>");

HTMLString.Append("</body></html>");

//Set the Text property to the HTML string.

notification1.Text = HTMLString.ToString();

notification1.Caption = "Notification Demo";

notification1.Critical = false;

// Display icon up to 10 seconds.

notification1.InitialDuration = 10;

notification1.Visible = true;

}

我们在窗体上添加一个Button和一个TextBox,在Button的响应函数中加入上面的代码。这些代码是来自于MSDN

然后我们再添加Notification控件的事件响应函数。选中Notification控件,在属性窗口中选择“事件”(那个闪电型的图标),然后双击ResponseSubmitted事件。

<shape id="_x0000_i1026" style="WIDTH: 279.75pt; HEIGHT: 231pt" type="#_x0000_t75"></shape><imagedata src="file:///C:%5CDOCUME~1%5Cmaning%5CLOCALS~1%5CTemp%5Cmsohtml1%5C01%5Cclip_image002.jpg" o:title="notify_event"></imagedata>

在事件处理函数中添加下面的代码:

private void notification1_ResponseSubmitted(object sender, Microsoft.WindowsCE.Forms.ResponseSubmittedEventArgs e)

{

if (e.Response.Substring(0, 6) == "notify")

{

// Add code here to respond to the notification.

textBox1.Text = e.Response.ToString();

}

}

好了,最后让我们看一下执行的效果如何。

<shape id="_x0000_i1027" style="WIDTH: 180pt; HEIGHT: 240pt" type="#_x0000_t75"></shape><imagedata src="file:///C:%5CDOCUME~1%5Cmaning%5CLOCALS~1%5CTemp%5Cmsohtml1%5C01%5Cclip_image003.jpg" o:title="notify_CEZoom1"></imagedata>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值