没有标题栏的C#无边框表单 [英] C# borderless form without titlebar

查看:171
本文介绍了没有标题栏的C#无边框表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿那里,



我想创建一个只有windows-aero边框的表单(在win 10中带有阴影的蓝线)没有标题吧。

保持调整大小功能非常重要。



我的问题是顶部的白线,你可以看到此屏幕截图:

problem.PNG - Google Drive [ ^ ]





请帮帮我



最好的问候

TobiasWälde



我的尝试:



Hey there,

I want to create a form which has only the windows-aero border (in win 10 the blue line with the shadow) without the title bar.
It is very important to keep the resizing function.

My problem is the white line at the top which you can see on this screenshot:
problem.PNG - Google Drive[^]


Please help me

Best Regards
Tobias Wälde

What I have tried:

this.BorderStyle = FormBorderStyle.SizableToolWindow;
this.ControlBox = false;
this.Text = String.Empty;

推荐答案

Winform太难做了。但是没有阴影它可能,可能 - 你需要创建自己的自定义阴影。

通过将你的winform转换为控制libary

然后使用WindowsFormsIntegration并在WPF中尝试它,如果它可能
Winform is too hard to do like that. but Without Shadow it's possible, May be - You need to create your own custom shadow.
by convert yourWinform to control libary
then use WindowsFormsIntegration and try it in WPF, if its possible


我很久没有完成WinForms了,但是请尝试使用FormBorderStyle.FixedSingle。



EDIT == ===========================



您可以随时使用互操作和使用用于设置窗口样式的Win32 API。这是一种参与,但它完全有可能做到。请记住,一旦取下标题栏,用户就无法移动窗口,除非您编写代码以允许它(如果我没记错,您感兴趣的API方法是CreateWindowEx)。查看www.pinvoke.net - 他们有原型和常量可用于支持大多数Windows API方法。



您尝试做的事情不符合Windows UI最佳实践,因此期望必须编写一堆奇怪的代码来实现您的梦想。根据我的经验,您的典型用户浪费了非标准用户界面,他们只想完成工作并关闭应用程序。只是说...
I haven't done WinForms in a long time, but try FormBorderStyle.FixedSingle instead.

EDIT =============================

You can always use interop and use the Win32 API to set the window style. It's kind of involved, but it's entirely possible do do. Keep in mind that once you take off the titlebar, the user can't move the window unless you write code to allow it (if I recall correctly, the API method you're interested in is CreateWindowEx). Check out www.pinvoke.net - they have prototypes and constants available fot support most Windows API methods.

What you're trying to do does not comply with the Windows UI best practice, so expect to have to write a bunch of weird code to realize your dream. It has been my experience that a non-standard UI are wasted on your typical user, who simply want to get the job done and close the app. Just sayin...


关于你可以做的最好的事情是将ControlBox属性设置为 false ,并将Text属性设置为空字符串。它在顶部留下一个短条(大约5个像素),但它仍然可用且相当大。
About the best you can do is to set the ControlBox property to false, and the Text property to an empty string. It leaves a "short" bar at the top (about 5 pixels) but it remains usable and sizeable.


这篇关于没有标题栏的C#无边框表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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