C#的位置窗口在桌面 [英] C# Position Window On Desktop

查看:236
本文介绍了C#的位置窗口在桌面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以说我有在C#中一个普通的窗口。它没有边框样式,因此它不能被移动或调整大小等,我怎么就这么出现在同一级别的桌面或以上的?

Lets say I have a plain window in C#. It has no border styles so it cannot be moved or resized etc. How would i position that window so it appears at the same level as the desktop or one above?

就像立场窗口一个小部件或皮肤的Rainmeter。 ?任何想法

Like a widget or a rainmeter skin. Any ideas?

推荐答案

如果我理解正确,你想画在桌面上,基本上,那么这可能帮助:< A HREF =htt​​p://www.neowin.net/forum/lofiversion/index.php/t293883.html> http://www.neowin.net/forum/lofiversion/index.php/t293883.html

If I understand you correctly and you want to draw on the desktop, basically, then this might help: http://www.neowin.net/forum/lofiversion/index.php/t293883.html

[DllImport("user32.dll", CharSet=CharSet.Auto)]
 public static extern IntPtr FindWindow(
  [MarshalAs(UnmanagedType.LPTStr)] string lpClassName,
  [MarshalAs(UnmanagedType.LPTStr)] string lpWindowName);
[DllImport("user32.dll")]
 public static extern IntPtr SetParent(
  IntPtr hWndChild,      // handle to window
  IntPtr hWndNewParent   // new parent window
  );


IntPtr hwndf = this.Handle;
IntPtr hwndParent = FindWindow("ProgMan", null);
SetParent(hwndf,hwndParent);
this.TopMost = false;

这将重定位你的形式桌面本身的子窗口。

That would reparent your form as a child window of the desktop itself.

阅读代码一些更多的时间后,我不知道为什么他们使用FindWindow函数()寻找PROGMAN,而不是使用

After reading the code some more times I'm not sure why they use FindWindow() looking for "ProgMan" instead of using

[DllImport("user32.dll")]
static extern IntPtr GetDesktopWindow();



但我没有给它一个尝试自己为止。

but I didn't give it a try myself so far.

这篇关于C#的位置窗口在桌面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆