高分求助api问题 怎么用api设置桌面图标自动排列为false,还有自动隐藏??希望大家给想想,急用!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.applevb.com/sourcecode/deskicon.zip using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Runtime.InteropServices;namespace 隐藏显示桌面或任务栏{ public partial class Form1 : Form { [DllImport("user32.dll", EntryPoint = "FindWindow")] public static extern int FindWindow( string lpClassName, int lpWindowName ); [DllImport("user32.dll", EntryPoint = "ShowWindow")] public static extern int ShowWindow( int hwnd, int nCmdShow ); [DllImport("user32.dll", EntryPoint = "FindWindowEx")] public static extern int FindWindowEx( int hWnd1, int hWnd2, string lpsz1, int lpsz2 ); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { int hwnd,child; hwnd = FindWindow("progman", 0); hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0); child = FindWindowEx(hwnd, 0, "SysListView32", 0); ShowWindow(child, 0); } private void button2_Click(object sender, EventArgs e) { int hwnd, child; hwnd = FindWindow("progman", 0); hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0); child = FindWindowEx(hwnd, 0, "SysListView32", 0); ShowWindow(child,1); } }} 给你个VBS的http://www.mybat.cn/forum/viewthread.php?tid=908 参考一些其它人的using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Runtime.InteropServices;namespace WindowsApplication1{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } [DllImport("user32.dll", EntryPoint = "FindWindow")] public static extern int FindWindow( string lpClassName, int lpWindowName ); [DllImport("user32.dll", EntryPoint = "ShowWindow")] public static extern int ShowWindow( int hwnd, int nCmdShow ); [DllImport("user32.dll", EntryPoint = "FindWindowEx")] public static extern int FindWindowEx( int hWnd1, int hWnd2, string lpsz1, int lpsz2 ); [DllImport("user32.dll")] public static extern int SetWindowLong( IntPtr hwnd, int nIndex, int dwNewLong ); [DllImport("user32.dll")] public static extern int GetWindowLong(IntPtr hWnd, int nIndex); private void HideIcon(object sender, EventArgs e) { int hwnd,child; hwnd = FindWindow("progman", 0); hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0); child = FindWindowEx(hwnd, 0, "SysListView32", 0); ShowWindow(child, 0); } private void ShowIcon(object sender, EventArgs e) { int hwnd, child; hwnd = FindWindow("progman", 0); hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0); child = FindWindowEx(hwnd, 0, "SysListView32", 0); ShowWindow(child,1); } const int GWL_STYLE = -16; const int LVS_AUTOARRANGE = 0x0100; private void DisableAutoArrange(object sender, EventArgs e) { int hwnd, child; hwnd = FindWindow("progman", 0); hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0); child = FindWindowEx(hwnd, 0, "SysListView32", 0); int oldValue=GetWindowLong(new IntPtr(child),GWL_STYLE); SetWindowLong(new IntPtr(child), GWL_STYLE, oldValue & ~LVS_AUTOARRANGE); } private void EnableAutoArrange(object sender, EventArgs e) { int hwnd, child; hwnd = FindWindow("progman", 0); hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0); child = FindWindowEx(hwnd, 0, "SysListView32", 0); int oldValue = GetWindowLong(new IntPtr(child), GWL_STYLE); SetWindowLong(new IntPtr(child), GWL_STYLE, oldValue & LVS_AUTOARRANGE); } }} 更改auto arrange不能反映在菜单上 但可以拖动图标检查效果 我试了试,怎么不行啊~~调用EnableAutoArrange这个方法,怎么连桌面图标都不能拖动了啊~对了,楼上,我说错了应该是“自动排列”和“对齐到网格”再给说一下好吗?分给定你了~~ EnableAutoArrange后确实不能拖动图标 要不怎么自动排列下边是对齐到网格的代码const int LVM_First = 0x1000; const int LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_First + 54; const int LVS_EX_SNAPTOGRID = 0x00080000; [DllImport("user32.dll", CharSet = CharSet.Unicode)] public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); private void EnableAlignToGrid(object sender, EventArgs e) { int hwnd, child; hwnd = FindWindow("progman", 0); hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0); child = FindWindowEx(hwnd, 0, "SysListView32", 0); SendMessage(new IntPtr(child), LVM_SETEXTENDEDLISTVIEWSTYLE, new IntPtr(LVS_EX_SNAPTOGRID), new IntPtr(LVS_EX_SNAPTOGRID)); } private void DisableAlignToGrid(object sender, EventArgs e) { int hwnd, child; hwnd = FindWindow("progman", 0); hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0); child = FindWindowEx(hwnd, 0, "SysListView32", 0); SendMessage(new IntPtr(child), LVM_SETEXTENDEDLISTVIEWSTYLE, new IntPtr(LVS_EX_SNAPTOGRID), IntPtr.Zero); } 对齐网格很正确啊!!谢谢,Macosx了你真厉害啊~~ 借楼主一个光,想请问一下大虾们,在哪里有C#的WinApi资料? 请问com.excel这个在哪里调用 验证登陆的页面。求助代码如何写,原理,方案我已经完全知道了 求助:NativeMethods 如何引用?? Gridview分页后导出excel,只能导入一页 在VS08中动态连接怎么调试存储过程呢? 如何将数组转换成Int数据? (vs.net2005)打开窗体设计器时弹出错误消息框“确保已安装文件类型(.cs)应用程序” 有人做過C# 調用 Native Java API嗎? 关于C# 与三层结构的问题 win2003安装vs2003携带的msdn文档不能使用如何解决 C# panel中绘图Graphics问题,怎么锁定? 新手
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;namespace 隐藏显示桌面或任务栏
{
public partial class Form1 : Form
{
[DllImport("user32.dll", EntryPoint = "FindWindow")]
public static extern int FindWindow(
string lpClassName,
int lpWindowName
); [DllImport("user32.dll", EntryPoint = "ShowWindow")]
public static extern int ShowWindow(
int hwnd,
int nCmdShow
); [DllImport("user32.dll", EntryPoint = "FindWindowEx")]
public static extern int FindWindowEx(
int hWnd1,
int hWnd2,
string lpsz1,
int lpsz2
);
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{ } private void button1_Click(object sender, EventArgs e)
{
int hwnd,child;
hwnd = FindWindow("progman", 0);
hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0);
child = FindWindowEx(hwnd, 0, "SysListView32", 0);
ShowWindow(child, 0);
} private void button2_Click(object sender, EventArgs e)
{
int hwnd, child;
hwnd = FindWindow("progman", 0);
hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0);
child = FindWindowEx(hwnd, 0, "SysListView32", 0);
ShowWindow(child,1);
}
}
}
http://www.mybat.cn/forum/viewthread.php?tid=908
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} [DllImport("user32.dll", EntryPoint = "FindWindow")]
public static extern int FindWindow(
string lpClassName,
int lpWindowName
); [DllImport("user32.dll", EntryPoint = "ShowWindow")]
public static extern int ShowWindow(
int hwnd,
int nCmdShow
); [DllImport("user32.dll", EntryPoint = "FindWindowEx")]
public static extern int FindWindowEx(
int hWnd1,
int hWnd2,
string lpsz1,
int lpsz2
); [DllImport("user32.dll")]
public static extern int SetWindowLong(
IntPtr hwnd,
int nIndex,
int dwNewLong
);
[DllImport("user32.dll")]
public static extern int GetWindowLong(IntPtr hWnd,
int nIndex); private void HideIcon(object sender, EventArgs e)
{
int hwnd,child;
hwnd = FindWindow("progman", 0);
hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0);
child = FindWindowEx(hwnd, 0, "SysListView32", 0);
ShowWindow(child, 0);
} private void ShowIcon(object sender, EventArgs e)
{
int hwnd, child;
hwnd = FindWindow("progman", 0);
hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0);
child = FindWindowEx(hwnd, 0, "SysListView32", 0);
ShowWindow(child,1);
} const int GWL_STYLE = -16;
const int LVS_AUTOARRANGE = 0x0100; private void DisableAutoArrange(object sender, EventArgs e)
{
int hwnd, child;
hwnd = FindWindow("progman", 0);
hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0);
child = FindWindowEx(hwnd, 0, "SysListView32", 0);
int oldValue=GetWindowLong(new IntPtr(child),GWL_STYLE);
SetWindowLong(new IntPtr(child), GWL_STYLE, oldValue & ~LVS_AUTOARRANGE);
} private void EnableAutoArrange(object sender, EventArgs e)
{
int hwnd, child;
hwnd = FindWindow("progman", 0);
hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0);
child = FindWindowEx(hwnd, 0, "SysListView32", 0);
int oldValue = GetWindowLong(new IntPtr(child), GWL_STYLE);
SetWindowLong(new IntPtr(child), GWL_STYLE, oldValue & LVS_AUTOARRANGE);
}
}
}
调用EnableAutoArrange这个方法,怎么连桌面图标都不能拖动了啊~
对了,楼上,我说错了应该是“自动排列”和“对齐到网格”
再给说一下好吗?
分给定你了~~
下边是对齐到网格的代码
const int LVM_First = 0x1000;
const int LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_First + 54;
const int LVS_EX_SNAPTOGRID = 0x00080000; [DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); private void EnableAlignToGrid(object sender, EventArgs e)
{
int hwnd, child;
hwnd = FindWindow("progman", 0);
hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0);
child = FindWindowEx(hwnd, 0, "SysListView32", 0);
SendMessage(new IntPtr(child), LVM_SETEXTENDEDLISTVIEWSTYLE, new IntPtr(LVS_EX_SNAPTOGRID), new IntPtr(LVS_EX_SNAPTOGRID));
} private void DisableAlignToGrid(object sender, EventArgs e)
{
int hwnd, child;
hwnd = FindWindow("progman", 0);
hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0);
child = FindWindowEx(hwnd, 0, "SysListView32", 0);
SendMessage(new IntPtr(child), LVM_SETEXTENDEDLISTVIEWSTYLE, new IntPtr(LVS_EX_SNAPTOGRID), IntPtr.Zero);
}
谢谢,Macosx了
你真厉害啊~~