近期在做winCE系统的扫描枪应用程序,遇到了一些问题,其中包括消失提示框在手持终端显示过小,

用户要求提示框提示几秒后自动关闭,Windows平台可以通过调用系统API以定时器的方式进行自动销毁。

不过在winCE上存在不同,由于winCE系统属于精简版的windows系统,所以在API上也是属于精简后的,

Windows平台销毁消息框用user32.dll中的FindWindow和PostMessage完成,而winCE平台并没有

user32.dll,不过对应的API在coredll.dll中。

windows平台示例代码:

         [DllImport("user32.dll", EntryPoint = "FindWindow", CharSet = CharSet.Auto)]
internal static extern IntPtr FindWindow(string className,string windowName); [DllImport("user32.dll", EntryPoint = "PostMessage", CharSet = CharSet.Auto)]
internal static extern int PostMessage(IntPtr hWnd,int msg,IntPtr wParam,IntPtr lParam); internal const int WM_CLOSE = 0x10;
Timer timer = new Timer(); private void btnAutoCloseMesaage_Click(object sender, EventArgs e)
{
runKillTimer();
MessageBox.Show("操作已完成,可以关闭!","Message");
} /// <summary>
/// 运行timer
/// </summary>
internal void runKillTimer()
{
timer.Interval = ;
timer.Tick+=timer_Tick;
timer.Start();
} /// <summary>
/// timer触发关闭消息框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void timer_Tick(object sender, EventArgs e)
{
KillMessageBox();
timer.Stop();
} /// <summary>
/// 调用API查找窗体并关闭
/// </summary>
internal void KillMessageBox()
{
IntPtr msgPtr = FindWindow(null, "Message");
if (msgPtr != IntPtr.Zero)
{
PostMessage(msgPtr, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
}
}

winCE平台示例代码:

 [DllImport("coredll.dll", EntryPoint = "FindWindow", CharSet = CharSet.Auto)]
internal static extern IntPtr FindWindow(string className,string windowName); [DllImport("coredll.dll", EntryPoint = "PostMessage", CharSet = CharSet.Auto)]
internal static extern int PostMessage(IntPtr hWnd,int msg,IntPtr wParam,IntPtr lParam); internal const int WM_CLOSE = 0x10;
Timer timer = new Timer(); private void btnAutoCloseMesaage_Click(object sender, EventArgs e)
{
runKillTimer();
MessageBox.Show("操作已完成,可以关闭!","Message");
} /// <summary>
/// 运行timer
/// </summary>
internal void runKillTimer()
{
timer.Interval = ;
timer.Tick+=new EventHandler(timer_Tick);
timer.Enabled = true;
} /// <summary>
/// timer触发关闭消息框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void timer_Tick(object sender, EventArgs e)
{
KillMessageBox();
timer.Enabled = false;
} /// <summary>
/// 调用API查找窗体并关闭
/// </summary>
internal void KillMessageBox()
{
IntPtr msgPtr = FindWindow(null, "Message");
if (msgPtr != IntPtr.Zero)
{
PostMessage(msgPtr, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
}
}

ps:大家有其他好的意见或建议也可以多多交流。

winCE/Windows 应用程序消息提示框自动消失功能的更多相关文章

  1. Android检测WIFI连接、提示框延时消失

    Android检测系统WIFI是否连接?如没有连接,显示提示框,提示进行设置,当点击设置进入系统WIFI界面后1秒钟,提示框自动消失. 代码: ? 1 2 3 4 5 6 7 8 9 10 11 12 ...

  2. 微信小程序之----消息提示框toast

    toast toast为消息提示框,无按钮,如需关闭弹框可以添加事件设置hidden为true,在弹框显示后经过duration指定的时间后触发bindchange绑定的函数. 官方文档 .wxml ...

  3. 微信小程序API交互反馈,wx.showToast显示消息提示框

    导读:wx.showToast(OBJECT) 显示消息提示框. OBJECT参数说明: 参数 类型 必填 说明 最低版本 title String 是 提示的内容 icon String 否 图标, ...

  4. Springboot+Vue实现仿百度搜索自动提示框匹配查询功能

    案例功能效果图 前端初始页面 输入搜索信息页面 点击查询结果页面 环境介绍 前端:vue 后端:springboot jdk:1.8及以上 数据库:mysql 核心代码介绍 TypeCtrler .j ...

  5. 自定义iOS 中推送消息 提示框

    看到标题你可能会觉得奇怪 推送消息提示框不是系统自己弹出来的吗? 为什么还要自己自定义呢? 因为项目需求是这样的:最近需要做 远程推送通知 和一个客服系统 包括店铺客服和官方客服两个模块 如果有新的消 ...

  6. Android:Toast简单消息提示框

    Toast是简单的消息提示框,一定时间后自动消失,没有焦点. 1.简单文本提示的方法: Toast.makeText(this, "默认的toast", Toast.LENGTH_ ...

  7. Android应用开发学习之Toast消息提示框

    作者:刘昊昱 博客:http://blog.csdn.net/liuhaoyutz 本文我们来看Toast消息提示框的用法.使用Toast消息提示框一般有三个步骤: 1.  创建一个Toast对象.可 ...

  8. Android消息提示框Toast

    Android消息提示框Toast Toast是Android中一种简易的消息提示框.和Dialog不一样的是,Toast是没有焦点的,toast提示框不能被用户点击,而且Toast显示的时间有限,t ...

  9. PowerShe 消息提示框测试

    1. 使用powerShell 弹出一个简单的消息框,代码如下,创建test.ps1脚本文件. $ConfirmPreference = 'None' $ws = New-Object -ComObj ...

随机推荐

  1. 将pip源更换到国内镜像

    将pip源更换到国内镜像用pip管理工具安装库文件时,默认使用国外的源文件,因此在国内的下载速度会比较慢,可能只有50KB/s.幸好,国内的一些顶级科研机构已经给我们准备好了各种镜像,下载速度可达2M ...

  2. Flater-Provide狀態管理

    參考來源:http://www.jspang.com/posts/2019/03/01/flutter-shop.html#%E7%AC%AC24%E8%8A%82%EF%BC%9Aprovide%E ...

  3. 点击链接跳转到QQ的情况; qq交谈

    https://blog.csdn.net/qq_31856835/article/details/70225968 https://blog.csdn.net/qq_37815596/article ...

  4. 表单-angular

    模板表单: <form #myform="ngForm" (ngSubmit)="onsubmit(myform.value)" > <div ...

  5. 关于本地使用antd的upload组件上传文件,ngnix报错405的问题

    使用阿里的ui框架antd的upload,会自动请求ngnix上面的一个路径,也就是action所在的位置,一直报错405 not allowed,后来经讨论,统一将action写成一个路径,后端对这 ...

  6. Quartz常规操作

    原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/11899532.html Project Directory Maven Dependency < ...

  7. vue中的v-model原理,与组件自定义v-model

    VUE中的v-model可以实现双向绑定,但是原理是什么呢?往下看看吧 根据官方文档的解释,v-model其实是一个语法糖,它会自动的在元素或者组件上面解析为 :value="" ...

  8. postman-关联

    1.提取 在Tests提取接口1的值如:userid //将获取的json数据赋给变量 var jsonData=pm.response.json(); //获取返回的userid值 user_id= ...

  9. POJ 1161 Walls ( Floyd && 建图 )

    题意 :  在某国,城市之间建起了长城,每一条长城连接两座城市.每条长城互不相交.因此,从一个区域到另一个区域,需要经过一些城镇或者穿过一些长城.任意两个城市A和B之间最多只有一条长城,一端在A城市, ...

  10. 【ELK】elasticsearch设置密码访问

    1.需要在配置文件中开启x-pack验证, 修改config目录下面的elasticsearch.yml文件,在里面添加如下内容,并重启. xpack.security.enabled: true x ...