【发布时间】:2014-07-25 22:56:04
【问题描述】:
好的,这就是我想要实现的目标:
我希望所有无序的桌面图标在单击按钮时将自己排列在桌面的左上角。
这是我正在使用的代码:
[DllImport("user32.dll")]
private static extern IntPtr GetDesktopWindow();
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SendMessage(IntPtr hWnd, uint Msg, uint wParam, int lParam);
private void button1_Click(object sender, EventArgs e)
{
IntPtr hwnd = GetDesktopWindow(); //hwnd for desktop
SendMessage(hwnd, LVM_ARRANGE, LVA_ALIGNLEFT, 0);
}
我相信有与LVM_ARRANGE 和LVA_ALIGNLEFT 相关的未分配整数,谁能指导我它们是什么。我不熟悉使用 dll,如果我问了一个愚蠢的问题,请原谅我。
谢谢!
帮帮我,我正在使用以下代码,但仍然无法正常工作:
private void button1_Click(object sender, EventArgs e)
{
IntPtr hanle = GetHandle();
IntPtr done;
done = SendMessage(hanle, LVM_ARRANGE, LVA_ALIGNLEFT, IntPtr.Zero);
}
public IntPtr GetHandle()
{
hShellWnd = GetShellWindow();
hDefView = FindWindowEx(hShellWnd, IntPtr.Zero, "SHELLDLL_DefView", null);
folderView = FindWindowEx(hDefView, IntPtr.Zero,"SysListView32", null);
return folderView;
}
public const int LVM_FIRST = 0x1000;
public const uint LVM_ARRANGE = LVM_FIRST + 22;
//public const IntPtr LVA_SNAPTOGRID = 5;
IntPtr LVA_ALIGNLEFT = new IntPtr(0x0001);
IntPtr hShellWnd;
IntPtr hDefView;
IntPtr folderView;
[DllImport("User32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr GetDesktopWindow();
[DllImport("user32.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, string windowTitle);
[DllImport("user32.dll")]
static extern IntPtr GetShellWindow();
【问题讨论】:
-
我的意思是图标...
-
你可以检查source.winehq.org/source/include/commctrl.h 的 LVM_* 和 LVA_* 符号的值(我希望你有基本的 C 阅读技能,因为链接会引导你到一个头文件。你也应该能够在与VS一起安装的平台SDK中找到commctrl.h文件...)
-
用户文档界面:SetCurrentFolderFlags.
-
-1 Raymond 已经告诉你怎么做
-
能否详细说明...