C# creating a sticking windows on desktop with transperancy
Long title, but simple problem.
I am trying to let a window stick to the destop (or pin), I can do this like this:
[DllImport("User32.dll")]
static extern IntPtr FindWindow(String lpClassName, String lpWindowName);
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChild开发者_如何学运维After, string lpszClass, string lpszWindow);
[DllImport("user32.dll")]
static extern int SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
IntPtr pWnd = FindWindow("Progman", null);
pWnd = FindWindowEx(pWnd, IntPtr.Zero, "SHELLDLL_DefVIew", null);
pWnd = FindWindowEx(pWnd, IntPtr.Zero, "SysListView32", null);
IntPtr tWnd = this.Handle;
SetParent(tWnd, pWnd);
This works fine, but I cannot change transperancy or opacitiy.
I can use CreateWindowEx to create a nice transparent window layered, but then this methode does not work anymore to pin it to the desktop!
Anybody know's how this can be done?
Thank!
Only top-level windows can be created as layered. With your approach, you are creating a child window to the desktop window, hence it can't be layered.
It might be better if you try to explain what you mean by "sticking"/"pinning" a window to the desktop. I assume that you want to set the window at particular position on the desktop and keep it always there, but there must be something more to it which I am missing. Otherwise, why wouldn't just positioning the window at particular coordinates on the screen not work for you?
精彩评论