问题描述
你好.
我尝试创建像HyperSpace 3D这样的动画墙纸.
但是我有一个问题:
我要做什么(代码段):
[DllImport("user32.dll")]
公共静态外部IntPtr SetParent(IntPtr hWndChild,IntPtr hWndNewParent);
[DllImport("user32.dll")]
公共静态外部IntPtr FindWindow(string lpClassName,string lpWindowName);
[DllImport("user32.dll")]
公共静态外部IntPtr FindWindowEx(IntPtr hwndParent,IntPtr hwndChildAfter,字符串lpszClass,字符串lpszWindow);
[DllImport("User32.DLL")]
公共静态外部int SendMessage(IntPtr hWnd,UInt32 Msg,Int32 wParam,Int32 lParam);
[DllImport("user32.dll",SetLastError = true)]
公共静态外部布尔SetWindowPos(IntPtr hWnd,IntPtr hWndInsertAfter,int x,int y,int cx,int cy,uint uFlags);
[DllImport("user32.dll",CharSet = CharSet.Auto,SetLastError = true)]
public static extern long SetWindowLong(IntPtr hWnd,int nIndex,long dwNewLong);
公共长WS_CHILD = 0x40000000L,WS_VISIBLE = 0x10000000L,
WS_DISABLED = 0x08000000L,
WS_CLIPSIBLINGS = 0x04000000L,
WS_CLIPCHILDREN = 0x02000000L,
WS_EX_TRANSPARENT = 0x00000020L,WS_EX_RIGHTSCROLLBAR = 0x00000000L,WS_EX_LEFT = 0x00000000L,
WS_EX_LTRREADING = 0x00000000L,
SWP_NOSIZE = 0x0001,
SWP_NOMOVE = 0x0002;
public int LVM_SETEXTENDEDLISTVIEWSTYLE = 0x1000 + 54,GWL_STYLE =(-16),
GWL_EXSTYLE =(-20),LVS_EX_REGIONAL = 0x00000200;
IntPtr SysListView32;
private void button1_Click(对象发送者,EventArgs e)
{
IntPtr Progman = FindWindow("Progman",null);
IntPtr ShellDll = FindWindowEx(Progman,IntPtr.Zero,"SHELLDLL_DefView",null);
SysListView32 = FindWindowEx(ShellDll,IntPtr.Zero,"SysListView32",null);
表格TestForm = new Form();
TestForm.FormBorderStyle = FormBorderStyle.None;
TestForm.Width = Screen.PrimaryScreen.WorkingArea.Width;
TestForm.Height = Screen.PrimaryScreen.WorkingArea.Height;
TestForm.Top = 0; TestForm.Left = 0;
TestForm.Text ="TestApp";
SetWindowLong(TestForm.Handle,GWL_STYLE,WS_CHILD | WS_CLIPCHILDREN | WS_DISABLED | WS_VISIBLE);
SetWindowLong(TestForm.Handle,GWL_EXSTYLE,WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR/* | WS_EX_TRANSPARENT */);
SetParent(TestForm.Handle,ShellDll);
SendMessage(SysListView32,(uint)LVM_SETEXTENDEDLISTVIEWSTYLE,LVS_EX_REGIONAL,LVS_EX_REGIONAL);
bool ret = SetWindowPos(TestForm.Handle,SysListView32,0,0,0,0,(uint)(SWP_NOSIZE));
}
如果将运行此代码,您会看到我的窗口和"HyperSpace 3D"窗口之间的许多差异.这些差异体现在视觉风格和行为上.我希望获得与HyperSpace 3D相同的行为和视觉样式.请帮帮我.
对不起,我的英语:)
Hello.
I try to create animated wallpaper like HyperSpace 3D.
But I''ve got a problem:
What I do(code snippet):
[DllImport("user32.dll")]
public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("User32.DLL")]
public static extern int SendMessage(IntPtr hWnd, UInt32 Msg, Int32 wParam, Int32 lParam);
[DllImport("user32.dll", SetLastError = true)]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern long SetWindowLong(IntPtr hWnd, int nIndex, long dwNewLong);
public long WS_CHILD = 0x40000000L, WS_VISIBLE = 0x10000000L,
WS_DISABLED = 0x08000000L,
WS_CLIPSIBLINGS = 0x04000000L,
WS_CLIPCHILDREN = 0x02000000L,
WS_EX_TRANSPARENT = 0x00000020L, WS_EX_RIGHTSCROLLBAR = 0x00000000L, WS_EX_LEFT = 0x00000000L,
WS_EX_LTRREADING = 0x00000000L,
SWP_NOSIZE = 0x0001,
SWP_NOMOVE = 0x0002;
public int LVM_SETEXTENDEDLISTVIEWSTYLE = 0x1000 + 54, GWL_STYLE = (-16),
GWL_EXSTYLE = (-20), LVS_EX_REGIONAL = 0x00000200;
IntPtr SysListView32;
private void button1_Click(object sender, EventArgs e)
{
IntPtr Progman = FindWindow("Progman",null);
IntPtr ShellDll = FindWindowEx(Progman, IntPtr.Zero, "SHELLDLL_DefView",null);
SysListView32 = FindWindowEx(ShellDll, IntPtr.Zero,"SysListView32",null);
Form TestForm = new Form();
TestForm.FormBorderStyle = FormBorderStyle.None;
TestForm.Width = Screen.PrimaryScreen.WorkingArea.Width;
TestForm.Height = Screen.PrimaryScreen.WorkingArea.Height;
TestForm.Top = 0; TestForm.Left = 0;
TestForm.Text = "TestApp";
SetWindowLong(TestForm.Handle, GWL_STYLE, WS_CHILD | WS_CLIPCHILDREN | WS_DISABLED | WS_VISIBLE);
SetWindowLong(TestForm.Handle, GWL_EXSTYLE, WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR /*| WS_EX_TRANSPARENT*/);
SetParent(TestForm.Handle, ShellDll);
SendMessage(SysListView32, (uint)LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_REGIONAL, LVS_EX_REGIONAL);
bool ret = SetWindowPos(TestForm.Handle, SysListView32, 0, 0, 0, 0, (uint)(SWP_NOSIZE));
}
If you will run this code, you see many differences between my window and ''HyperSpace 3D'' window. These differences are in visual style and behaviour. I want get the same behaviour and visual style like HyperSpace 3D. Please, help me.
Sorry for my English:)
推荐答案
这篇关于如何创建动画墙纸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!