c#消除通知区域死程序图标
2006-01-15 00:48
435 查看
前两天在csdn上看到有人问这个问题,以前就弄过,不过没出结果,今天用spy++终于找到了,哈哈哈
贴代码最直接! 转载请注明作者!
#region 常量和结构体定义
private const int WM_MOUSEMOVE = 0x0200;
[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode)]
private struct RECT
{
internal int left;
internal int top;
internal int right;
internal int bottom;
}
#endregion
#region P/Invoke
[DllImport("User32.dll",EntryPoint="FindWindow")]
private static extern IntPtr FindWindow(string lpClassName,string lpWindowName);
[DllImport("User32.dll",EntryPoint="FindWindowEx")]
private static extern IntPtr FindWindowEx(IntPtr hwndParent,IntPtr hwndChildAfter,
string lpClassName,string lpWindowName);
[DllImport("User32.dll",EntryPoint="GetClientRect")]
static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect);
[DllImport("user32.dll", EntryPoint="PostMessageA")]
private static extern int PostMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
#endregion
private void button1_Click(object sender, System.EventArgs e)
{
IntPtr hParent = FindWindow("Shell_TrayWnd",null);
if(hParent!=IntPtr.Zero)
{
IntPtr hChild;
do
hChild = FindWindowEx(hParent,IntPtr.Zero,"TrayNotifyWnd",null);
while(hChild==IntPtr.Zero);
if(hChild!=IntPtr.Zero)
{
IntPtr hPager;
do
hPager = FindWindowEx(hChild,IntPtr.Zero,"SysPager",null);
while(hPager==IntPtr.Zero);
if(hPager!=IntPtr.Zero)
{
IntPtr hTray;
do
hTray = FindWindowEx(hPager,IntPtr.Zero,"ToolbarWindow32",null);
while(hTray==IntPtr.Zero);
if(hTray!=IntPtr.Zero)
{
RECT r = new RECT();
GetClientRect(hTray,out r);
for(int i=0;i<r.right;i++)
PostMessage(hTray,WM_MOUSEMOVE,0,(0x000E0000+i));
}
}
}
}
程序就不解释了,就是用win32API查找窗体,最费劲的就是发现那个SysPager了,整了好半天,最后那个PostMessage里面的0x000E0000表示老鼠标的位置,高位表示y,低位表示x,不过看起来这么大功夫就为了消除那个死图标,不值~
贴代码最直接! 转载请注明作者!
#region 常量和结构体定义
private const int WM_MOUSEMOVE = 0x0200;
[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode)]
private struct RECT
{
internal int left;
internal int top;
internal int right;
internal int bottom;
}
#endregion
#region P/Invoke
[DllImport("User32.dll",EntryPoint="FindWindow")]
private static extern IntPtr FindWindow(string lpClassName,string lpWindowName);
[DllImport("User32.dll",EntryPoint="FindWindowEx")]
private static extern IntPtr FindWindowEx(IntPtr hwndParent,IntPtr hwndChildAfter,
string lpClassName,string lpWindowName);
[DllImport("User32.dll",EntryPoint="GetClientRect")]
static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect);
[DllImport("user32.dll", EntryPoint="PostMessageA")]
private static extern int PostMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
#endregion
private void button1_Click(object sender, System.EventArgs e)
{
IntPtr hParent = FindWindow("Shell_TrayWnd",null);
if(hParent!=IntPtr.Zero)
{
IntPtr hChild;
do
hChild = FindWindowEx(hParent,IntPtr.Zero,"TrayNotifyWnd",null);
while(hChild==IntPtr.Zero);
if(hChild!=IntPtr.Zero)
{
IntPtr hPager;
do
hPager = FindWindowEx(hChild,IntPtr.Zero,"SysPager",null);
while(hPager==IntPtr.Zero);
if(hPager!=IntPtr.Zero)
{
IntPtr hTray;
do
hTray = FindWindowEx(hPager,IntPtr.Zero,"ToolbarWindow32",null);
while(hTray==IntPtr.Zero);
if(hTray!=IntPtr.Zero)
{
RECT r = new RECT();
GetClientRect(hTray,out r);
for(int i=0;i<r.right;i++)
PostMessage(hTray,WM_MOUSEMOVE,0,(0x000E0000+i));
}
}
}
}
程序就不解释了,就是用win32API查找窗体,最费劲的就是发现那个SysPager了,整了好半天,最后那个PostMessage里面的0x000E0000表示老鼠标的位置,高位表示y,低位表示x,不过看起来这么大功夫就为了消除那个死图标,不值~
相关文章推荐
- 给MFC程序添加通知区域图标
- C# 右下角的通知区域显示 和 隐藏主窗体 以及 为通知区域图标添加菜单 等
- MFC程序添加通知区域图标
- MFC程序添加通知区域图标
- WPF 程序启动显示为通知区域的图标方法
- C# 程序关闭托盘图标不会自动消失
- C# 程序关闭托盘图标不会自动消失
- c#实现文件加密、解密及文件拖拽至程序图标直接打开(转)
- 清理Windows7通知区域的图标缓存
- window下删除无效的区域通知图标
- WIN7 UAC/结构体的Equals方法/C# 开发wince程序,窗口上总留有一块空白区域/静态构造函数
- 删除Win7通知区域的无效图标
- C#程序最小化到托盘图标
- C# 实现任务栏图标程序
- 用 C# 编写一个停放在任务栏上的图标程序
- 给C#2010程序添加图标
- wince程序 中使用Listview显示图标问题 (C#)
- C# 如何实现带消息数的程序桌面图标
- Win7删除桌面右下角任务栏通知区域带红叉的小白旗图标的方法