English 中文(简体)
1. 建立“视窗”是最底层
原标题:Setting a Windows form to be bottommost

Some background

我目前的客户之一拥有一个链路的互联网点,客户通过个人计算机获得该网:在用户签署之前,作为“千兆克”的定制应用“锁”计算机,通过Windows集团政策严格限制运行账户。 目前,每台计算机都运行Windows XP,并使用主动式台显示背景的广告。 然而,由于我的客户每天都在主动坠毁(除了一般放慢计算机外)方面遇到问题。 有人要求我拟订一份替代申请。

The problem

我正试图调查是否有可能建立“Windows”申请表(使用C#),always停留在背景。 申请应放在桌面上(以便涵盖任何信标、档案等),但始终落后于所有其他运行应用程序。 我猜测Im真的看望<条码>BottomMost> 代码 类别(当然有t)。

任何关于如何实现这一目标的表象或要点都将受到高度赞赏。

最佳回答

这没有得到直接支持。 NET 表格类别,因此有两种选择:

(1) 使用Win32 份标书SetWindowPos

pinvoke.net • 说明如何宣布这一点供C#使用:

[DllImport("user32.dll")]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);

static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
const UInt32 SWP_NOSIZE = 0x0001;
const UInt32 SWP_NOMOVE = 0x0002;
const UInt32 SWP_NOACTIVATE = 0x0010;

因此,在你的法典中呼吁:

SetWindowPos(Handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);

正如你评论的那样,这种形式向底部转移,但并没有保持。 我能看到的唯一工作是打上<条码>,SetWindowPos,从Form_LoadForm_Activate。 如果您的申请得到最大限度的利用,而且用户无法移动或尽量减少其形式,那么你可能会放弃这种做法,但这种做法仍然带有 ha。 如果表格在打电话之前被带至Z-order前线,用户也可看到略微的“flicker”。


2) ,优先于WndProc的功能,拦截。 WM_WINDOWPOSCHANGING 视窗信息,贴上SWP_NOZORDER国旗(从

问题回答

我认为,这样做的最佳方式是使用活性活动手和Send ToBack方法,例如:

private void Form1_Activated(object sender, EventArgs e)
{
    this.SendToBack();
}

www.un.org/Depts/DGACM/index_spanish.htm • 将你的窗户定为桌面的儿童窗户 (“Program Manager”或“progman”进程)。 I ve在Windows XP(x86)和Windowsista(x64)上继承了这种方法。

我在寻找一种方式使屏幕显示像是纸面显示时, st倒了这种方法。 反之,这是在系统上建立起来的。 您使用<条码>筛选/p PID<>/code>,而PID是另一个附加程序的过程。 因此,撰写了寻找亲人手的节目,然后援引这段话语作为/纸上的理由,并且你放映了平均的纸面!

目前,Im玩 playing的项目是台式状态显示器(如时间、一些任务、安装的软盘等),并在Salwberry Perl和Sang Win32S(主要是Win32:GUI和Win32:API模块)上建树,因此,该代码易于携带或理解任何具有类似Win32A普森约束装置的动态语言,或可进入Windows 读物(主机、主动Perl、Ze、J.VB )。 这里有制作窗口的一组相关部分:

do { Win32::API->Import(@$_) or die "Win32::API can t import @$_ ($^E)" } for
    [user32 =>  HWND FindWindow(LPCTSTR lpClassName, LPCTSTR lpWindowName) ],
    [user32 =>  HWND SetParent(HWND hWndChild, HWND hWndNewParent) ],

sub __screen_x {
    Win32::GUI::GetSystemMetrics(SM_CXSCREEN)
}
sub __screen_y {
    Win32::GUI::GetSystemMetrics(SM_CYSCREEN)
}
sub _create_window { # create window that covers desktop
    my $self = shift;
    my $wnd = $$self{_wnd} = Win32::GUI::Window->new(
        -width   => __screen_x(), -left => 0,
        -height  => __screen_y(), -top  => 0,
    ) or die "can t create window ($^E)";

    $wnd->SetWindowLong(GWL_STYLE,
        WS_VISIBLE
        | WS_POPUP # popup: no caption or border
    );
    $wnd->SetWindowLong(GWL_EXSTYLE, 
        WS_EX_NOACTIVATE # noactivate: doesn t activate when clicked
        | WS_EX_NOPARENTNOTIFY # noparentnotify: doesn t notify parent window when created or destroyed
        | WS_EX_TOOLWINDOW # toolwindow: hide from taskbar
    );
    SetParent($$wnd{-handle}, # pin window to desktop (bottommost)
        (FindWindow( Progman ,  Program Manager ) or die "can t find desktop window ($^E)")
    ) or die "can t pin to desktop ($^E)";
    Win32::GUI::DoEvents; # allow sizing and styling to take effect (otherwise DC bitmaps are the wrong size)
}

这项方案缓冲了防止浮油的输出,你可能希望这样做。 我创建了一个DC(发展中国家的背景)和绘画提交给它(你可以使用任何比图,只有两条更细的线——绘制目录,并选定比图作为粗纸处理),然后制造一个拥有缓冲的缓冲,以保存这一背景的清洁拷贝,并提供一个工作缓冲,以在每一座椅上组装碎块,在背景中复印件,然后绘制线和粗略的比图,然后将文本Out复制到原来的发展中国家,然后将其放在屏幕上。

表格分级,优先于电离层功能,并拦截视窗电文,因为电离层电离层电离层是电离层的。

设立一个小组,涵盖你的形式,但你在小组上所希望的内容,然后在小组的Click-Event上写这封信。 反馈。

I ve在使用窗户时设法清除了浮油。

const UInt32 SWP_NOSIZE = 0x0001;
const UInt32 SWP_NOMOVE = 0x0002;
const UInt32 SWP_NOACTIVATE = 0x0010;
const UInt32 SWP_NOZORDER = 0x0004;
const int WM_ACTIVATEAPP = 0x001C;
const int WM_ACTIVATE = 0x0006;
const int WM_SETFOCUS = 0x0007;
static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
const int WM_WINDOWPOSCHANGING = 0x0046;

[DllImport("user32.dll")]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X,
   int Y, int cx, int cy, uint uFlags);
[DllImport("user32.dll")]
static extern IntPtr DeferWindowPos(IntPtr hWinPosInfo, IntPtr hWnd,
   IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
[DllImport("user32.dll")]
static extern IntPtr BeginDeferWindowPos(int nNumWindows);
[DllImport("user32.dll")]
static extern bool EndDeferWindowPos(IntPtr hWinPosInfo);

private void Window_Loaded(object sender, RoutedEventArgs e)
{
    IntPtr hWnd = new WindowInteropHelper(this).Handle;
    SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);

    IntPtr windowHandle = (new WindowInteropHelper(this)).Handle;
    HwndSource src = HwndSource.FromHwnd(windowHandle);
    src.AddHook(new HwndSourceHook(WndProc));
}

private IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
    if (msg == WM_SETFOCUS)
    {
        IntPtr hWnd = new WindowInteropHelper(this).Handle;
        SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
        handled = true;
    }
    return IntPtr.Zero;
}

private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
    IntPtr windowHandle = (new WindowInteropHelper(this)).Handle;
    HwndSource src = HwndSource.FromHwnd(windowHandle);
    src.RemoveHook(new HwndSourceHook(this.WndProc));
}




相关问题
Bring window to foreground after Mutex fails

I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...

How to start WinForm app minimized to tray?

I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

WPF-XAML window in Winforms Application

I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.

热门标签