请问 C# 怎么能刷新 桌面呢? 我做了一个程序..可以改变壁纸...但是需要刷新桌面 ...怎么弄呢???帮帮忙 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 使用Win32API, 具体查一下Windows API手册吧. [DllImport("user32.dll")]public static extern bool InvalidateRect(IntPtr hwnd,IntPtr lpRect,bool bErase);private void button1_Click(object sender, System.EventArgs e){ InvalidateRect(IntPtr.Zero ,IntPtr.Zero ,true);} 用这个再试试:[DllImport("shell32.dll")]public static extern void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2);SHChangeNotify(0x8000000, 0, IntPtr.Zero, IntPtr.Zero); [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]public static extern IntPtr GetDesktopWindow();[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]public static extern bool RedrawWindow(IntPtr hwnd, RECT rcUpdate, IntPtr hrgnUpdate, int flags);RedrawWindow(GetDesktopWindow(), null, IntPtr.Zero, 0x85); 或使用[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]public static extern bool UpdateWindow(IntPtr hWnd); 测试:SHChangeNotify(0x8000000, 0, IntPtr.Zero, IntPtr.Zero); //可以。RedrawWindow(GetDesktopWindow(), null, IntPtr.Zero, 0x85);//不行UpdateWindow(GetDesktopWindow());//不行 //OS: vista 64bit. vs2008. 经测试, 注意 hwnd 这个参数的获取方式SHChangeNotify(0x8000000, 0, IntPtr.Zero, IntPtr.Zero); //可以,但是刷新时会闪屏,效果不好RedrawWindow(GetWindowDc(GetDesktopWindow()), null, IntPtr.Zero, 0x85);//可以刷新,也会闪屏 ,但是最后个参数错误。这个函数我没多作了解UpdateWindow(GetWindowDc(GetDesktopWindow()));//可以,楼主的参数错误,导致不能画图,这种方法的刷新效果比 SHChangeNotify 好很多。另外 PaintDesktop(GetWindowDc(GetDesktopWindow())); 也能够刷新桌面,用法跟 UpdateWindow 一样。基本上就是这样的情况了 DataGridView 中二个字段设置ComboBox C#如何调用php网站的api接口 麻烦各位高手帮忙分析一个登陆页面 C# 如何判断能否执行Undo和如何暂停记录Undo ??? 各位帮帮忙,datagridview打印日期数据格式问题 (100分)求助:上传到空间后出现问题 反射怎么做 Datagrid数据刷新问题 ?????????????? 如何注册net中的com组件-----送50分 winform导出Excel 怎样改变tabControl的TabPage的名称的字体的大小
public static extern bool InvalidateRect(IntPtr hwnd,IntPtr lpRect,bool bErase);
private void button1_Click(object sender, System.EventArgs e)
{
InvalidateRect(IntPtr.Zero ,IntPtr.Zero ,true);
}
public static extern void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2);
SHChangeNotify(0x8000000, 0, IntPtr.Zero, IntPtr.Zero);
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr GetDesktopWindow();
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern bool RedrawWindow(IntPtr hwnd, RECT rcUpdate, IntPtr hrgnUpdate, int flags);RedrawWindow(GetDesktopWindow(), null, IntPtr.Zero, 0x85);
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern bool UpdateWindow(IntPtr hWnd);
RedrawWindow(GetDesktopWindow(), null, IntPtr.Zero, 0x85);//不行
UpdateWindow(GetDesktopWindow());//不行
//OS: vista 64bit. vs2008.