首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

在程序里打一个外接程序,怎么让他一直位于顶端

2012-01-24 
在程序里打一个外接程序,如何让他一直位于顶端比如打开计算器或记事本。[解决办法]更改窗口的TOP_MOST[解决

在程序里打一个外接程序,如何让他一直位于顶端
比如打开计算器或   记事本。

[解决办法]
更改窗口的TOP_MOST



[解决办法]
using System.Runtime.InteropServices;

[DllImport( "user32.dll ")]
public static extern bool SetWindowPos(IntPtr hWnd,
IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
public IntPtr HWND_TOPMOST = new IntPtr(-1);
public uint SWP_NOMOVE = 2;
public uint SWP_NOSIZE = 1;
public uint SWP_NOACTIVATE = 0x10;
private void button1_Click(object sender, EventArgs e)
{
Process vProcess = Process.Start( "notepad.exe ");
while (vProcess.MainWindowHandle == IntPtr.Zero) vProcess.Refresh();
SetWindowPos(vProcess.MainWindowHandle, HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
}

热点排行