日期:2014-05-20  浏览次数:21142 次

高手救命~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~要死人了!!!!!!!!!
怎么隐藏Winform程序窗口   不管是任务栏   状态栏都不显示。用热键呼出。
怎么实现?????????????????

------解决方案--------------------
把透明度设成100 或隐藏掉都可以
------解决方案--------------------
任务栏 也不要? 用个托盘图标好了
------解决方案--------------------
最小化到托盘,用NotifyIcon组件~~
------解决方案--------------------
UP
------解决方案--------------------
不显示好说,先不在任务栏显示然后最小化就可以了.
但是 "呼出 "不好说...
------解决方案--------------------
首先不创建Form,注册一个Hook。。。然后呼叫以后创建Form
------解决方案--------------------
设置Visible=False
------解决方案--------------------
设置Form的属性 this.ShowInTaskbar = false; 并在Page_Load加入this.Hide();就可以实现启动窗口后自动隐藏了。

可用以下代码注册热键,并处理热键激活时的事件:


C#系统热键类
using System;
using System.Runtime.InteropServices;

namespace SystemHotKey
{
public delegate void HotkeyEventHandler(int HotKeyID);

public class Hotkey : System.Windows.Forms.IMessageFilter
{
System.Collections.Hashtable keyIDs = new System.Collections.Hashtable();
IntPtr hWnd;

public event HotkeyEventHandler OnHotkey;

public enum KeyFlags
{
MOD_ALT = 0x1,
MOD_CONTROL = 0x2,
MOD_SHIFT = 0x4,
MOD_WIN = 0x8
}
[DllImport( "user32.dll ")]
public static extern UInt32 RegisterHotKey(IntPtr hWnd, UInt32 id, UInt32 fsModifiers, UInt32 vk);

[DllImport( "user32.dll ")]
public static extern UInt32 UnregisterHotKey(IntPtr hWnd, UInt32 id);

[DllImport( "kernel32.dll ")]
public static extern UInt32 GlobalAddAtom(String lpString);

[DllImport( "kernel32.dll ")]
public static extern UInt32 GlobalDeleteAtom(UInt32 nAtom);

public Hotkey(IntPtr hWnd)
{
this.hWnd = hWnd;
System.Windows.Forms.Application.AddMessageFilter(this);
}

public int RegisterHotkey(System.Windows.Forms.Keys Key, KeyFlags keyflags)
{
UInt32 hotkeyid = GlobalAddAtom(System.Guid.NewGuid().ToString());
RegisterHotKey((IntPtr) hWnd, hotkeyid, (UInt32) keyflags, (UInt32) Key);
keyIDs.Add(hotkeyid, hotkeyid);
return (int) hotkeyid;
}

public void UnregisterHotkeys()
{
System.Windows.Forms.Application.RemoveMessageFilter(this);
foreach (UInt32 key in keyIDs.Values)
{
UnregisterHotKey(hWnd, key);
GlobalDeleteAtom(key);
}
}

public bool PreFilterMessage(ref System.Windows.Forms.Message m)
{
if (m.Msg == 0x312)
{
if (OnHotkey != null)
{
foreach (UInt32 key in keyIDs.Values)
{
if ((UInt32) m.WParam == key)
{
OnHotkey((int) m.WParam);
return true;
}