//调用Windows API 展示窗口到最前端
SwitchToThisWindow(this.Handle, true);//窗体的句柄 this.Handle

 
 
SwitchToThisWindow (user32)
 

Summary

Switches focus to a specified window and brings it to the foreground.

C# Signature:

[DllImport("user32.dll", SetLastError=true)]
static extern void SwitchToThisWindow(IntPtr hWnd, bool fAltTab);

VB Signature:

Declare Sub SwitchToThisWindow Lib "user32.dll" ( _
   hWnd As IntPtr, fAltTab As Boolean)

Notes:

Set fAltTab to true if you want it to work well for switching between applications. Otherwise won't work if application you're switching to is minimized.

Note that this function is deprecated and not intended for general use according to MSDN.

Tips & Tricks:

Please add some!

Sample Code:

static void Main()
    {
        int nIndex;

Process   procCurrent = Process.GetCurrentProcess();
        Process[] procProgram = Process.GetProcessesByName("Foo");

/* check if program is already running */
        if(procProgram.Length > 1)
        {
            for(nIndex = 0; nIndex < procProgram.Length; nIndex++)
            {
                /* switch to the other instance and let this one die */
                if(procProgram[nIndex].Id != procCurrent.Id)
                    SwitchToThisWindow(procProgram[nIndex].MainWindowHandle, true);
            }
        }
        else
        {
            /* enable visual style, most commonly associated with the XP operating system */
            Application.EnableVisualStyles();
            Application.DoEvents();
            Application.Run(new frmFoo());
        }
    }

点击Winform右下角图标,在最前端展示窗口的更多相关文章

  1. Windows右下角图标显示不正常

    我的win7系统,右下角图标透明,分不清哪个是哪个.点击也没有任何反应. 解决办法: 点击运行输入cmd,在命令提示符下输入下列命令即可恢复. taskkill /im explorer.exe /f ...

  2. jQuery之点击弹出图标环形菜单

    <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8&quo ...

  3. c#无标题窗体点击任务栏图标正常最小化或还原

    FormBorderStyle等于System.Windows.Forms.FormBorderStyle.None的窗体,点击任务栏图标的时候,是不能象标准窗体那样最小化或还原的. protecte ...

  4. C#实现无标题栏窗体点击任务栏图标正常最小化或还原的解决方法

    对于无标题栏窗体,也就是FormBorderStyle等于System.Windows.Forms.FormBorderStyle.None的窗体,点击任务栏图标的时候,是不能象标准窗体那样最小化或还 ...

  5. android点击桌面App图标activity启动流程

    1.点击桌面App图标,Launcher进程采用Binder IPC向system_server进程发起startActivity请求:2.system_server进程接收到请求后,向zygote进 ...

  6. JS 点击元素发ajax请求 打开一个新窗口

    JS 点击元素发ajax请求 打开一个新窗口 经常在项目中会碰到这样的需求,点击某个元素后,需要发ajax请求,请求成功以后,开发需要把链接传给前端(或者说请求成功后打开新窗口),前端需要通过新窗口打 ...

  7. 实时统计每天pv,uv的sparkStreaming结合redis结果存入mysql供前端展示

    最近有个需求,实时统计pv,uv,结果按照date,hour,pv,uv来展示,按天统计,第二天重新统计,当然了实际还需要按照类型字段分类统计pv,uv,比如按照date,hour,pv,uv,typ ...

  8. ASP.NET CORE使用WebUploader对大文件分片上传,并通过ASP.NET CORE SignalR实时反馈后台处理进度给前端展示

    本次,我们来实现一个单个大文件上传,并且把后台对上传文件的处理进度通过ASP.NET CORE SignalR反馈给前端展示,比如上传一个大的zip压缩包文件,后台进行解压缩,并且对压缩包中的文件进行 ...

  9. [py]access日志入mysql-通过flask前端展示

    目录 pymysql组装sql入库日志 代码组织 将入库的日志通过flask前端展示 pymysql组装sql入库日志 pymysql模块的用法 采集这些指标(metirc)都是linux环境,会用到 ...

随机推荐

  1. 优化C#程序的48种方法

    一.用属性代替可访问的字段 1..NET数据绑定只支持数据绑定,使用属性可以获得数据绑定的好处: 2.在属性的get和set访问器重可使用lock添加多线程的支持. 二.readonly(运行时常量) ...

  2. 【LeetCode练习题】Recover Binary Search Tree

    Recover Binary Search Tree Two elements of a binary search tree (BST) are swapped by mistake. Recove ...

  3. jquery 自动跳出列表

    先上效果图:当鼠标经过相亲会自动弹出取最新的10条数据

  4. [转]laravel 4之视图及Responses

    http://dingjiannan.com/2013/laravel-responses/   laravel 4之视图及Responses 16 Aug 2013 Laravel的Response ...

  5. RMAN简单备份

    检查目标数据库是否处于归档模式: . 检查数据库模式: sqlplus /nolog conn /as sysdba archive log list (查看数据库是否处于归档模式中) 若为非归档,则 ...

  6. python-布尔值

    布尔只有两个值:0,1 1或0 真或假 下面的值在作为布尔表达式的时候,会被解释器看作假(false) False    None    0   ""    ()    []   ...

  7. css基本属性

    CSS属性分类(最最常用的属性):颜色和长度文字盒模型布局定位背景文本和其他 常用CSS属性: <style>div{ color:#23729e; /*前景色*/ background: ...

  8. Installing the Eclipse Plugin

    Installing the Eclipse Plugin Android offers a custom plugin for the Eclipse IDE, called Android Dev ...

  9. Linux中oracle的安装,亲测

    一.下载oracle的软件包 地址: http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-li ...

  10. hdu 1587

    Problem Description As you know, Gardon trid hard for his love-letter, and now he's spending too muc ...