两句话搞定
[DllImport("user32.dll", CharSet = CharSet.Auto)]
 private static extern int SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int Width, int Height, int flags);

SetWindowPos(this.Handle, -1, 0, 0, 0, 0, 1 | 2);

namespace test
{
public partial class Form1 : Form
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern int SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int Width, int Height, int flags); public Form1()
{
InitializeComponent();
} protected override void OnLoad(EventArgs e)
{
SetWindowPos(this.Handle, -, , , , , | ); //最后参数也有用1 | 4 p1.MainForm.Handle 我记得这个是MainForm吧 反正是主窗口
SetWindowPos(this.printPreviewDialog1.Handle, -, , , , , | ); //最后参数也有用1 | 4 p1.MainForm.Handle 我记得这个是MainForm吧 反正是主窗口 }
}
}

C# window 窗体 保持最前显示的更多相关文章

  1. WPF自定义Window窗体样式

    资源文件代码: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation ...

  2. 第一次WM_PAINT事件执行前显示白色框 的解决办法

    界面显示前,总是会显示白色或白加黑的窗体, 开始以为是图片加载慢的原因,后来发现这个框是在第一次WM_PAINT执行前显示的. 解决办法很简单,在CreateWindow的时候,加上WS_POPUP样 ...

  3. [WPF自定义控件]?Window(窗体)的UI元素及行为

    原文:[WPF自定义控件]?Window(窗体)的UI元素及行为 1. 前言 本来打算写一篇<自定义Window>的文章,但写着写着发觉内容太多,所以还是把使用WindowChrome自定 ...

  4. wpf的UserControl用户控件怎么添加到Window窗体中

    转载自 http://www.cnblogs.com/shuang121/archive/2013/01/09/2853591.html 我们来新建一个用户控件UserControl1.xaml &l ...

  5. 非主窗体在任务栏显示按钮(简单好用)good

    非主窗体在任务栏显示按钮 type TForm2 = class(TForm) private { Private declarations } public { Public declaration ...

  6. 移动端弹窗滚动时window窗体也一起滚动的解决办法

    在做移动端项目的时候发现,如果弹窗的内容很多很长,在滑动弹窗时,蒙层下面的window窗体也会跟着一起滚动,这样带来很差的视觉体验:当时也想了很多办法,比如判断滑动的元素,如果是弹窗里面的元素则禁止w ...

  7. 测开之路九十九:js函数、事件、window窗体对象

    函数:function 函数名(参数列表) 事件 单击:onclick()表单提交:onsubmit()鼠标经过:onmouseover()值改表时:onchange() window窗体对象转跳:w ...

  8. DELPHI中如何让FORM窗体透明,只显示控件?

    DELPHI中如何让FORM窗体透明,只显示控件?分享到: 对我有用[0] 丢个板砖[0] 引用 | 举报 | 管理 回复次数:7largewanglargewanglargewang等级:Blank ...

  9. 【C#】DockPanelSuite 中 DockState.Document 状态下子窗体控件不显示的解决方案

    DockPanelSuite 是 Winform 中优秀的布局控件,但是这次使用过程中却出了个问题. 我遇到的问题是这样的,主窗体是通过 ShowDialog 显示的,子窗体的停靠状态为 DockSt ...

随机推荐

  1. django(二)视图和URL配置

    创建一份视图: 在上一节,使用django-admin.py startproject制作的mysite文件夹中,创建一个叫做views.py的空文件.这个Python模块健柏寒这一章的视图. vie ...

  2. express源码剖析--Router模块

    1.加载模块执行代码: methods.forEach(function(method){ //method是http协议的各种请求方法,如:get,put,headee,post Route.pro ...

  3. Windows 批处理文件

    窗口自动关闭:批处理文件执行完之后,窗口会自动关闭,若想执行完之后,窗口不自动关闭的话,在文件末尾添加1. 批处理文件执行完之后,窗口会自动关闭2. 若想执行完之后,窗口不自动关闭的话,在文件末尾添加 ...

  4. Ubuntu命令行下安装,卸载软件包的过程[转]

    一.Ubuntu中软件安装方法 1.APT方式 (1)普通安装:apt-get install softname1 softname2 …; (2)修复安装:apt-get -f install so ...

  5. rsyslog 解决日志截断不读取问题

    reopenOnTruncate [on/off] (requires v8.16.0+) Default: off 这是一个实验性的东西告诉rsyslog 重新input file 当它被trunc ...

  6. HDOJ 1390 Binary Numbers(进制问题)

    Problem Description Given a positive integer n, find the positions of all 1's in its binary represen ...

  7. cf509A Maximum in Table

    A. Maximum in Table time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  8. Stooge排序

    又叫臭皮匠排序... 在<算法导论>作为反例出现的漂亮但极其低效的排序算法. 基本思路是:只要数组长度大于3,先将头与尾排序,然后递归调用排序前三分之二,再递归调用排序后三分之二,最后再递 ...

  9. Bonobos | IT桔子

    Trumaker | IT桔子 Trumaker trumaker.com

  10. jdk各个版本的特性

    http://blog.csdn.net/mixiuali/article/details/8180100