创建一个没有边框的自定义部分半透明表单 [英] Creating a custom partly semi-transparant Form without border

查看:130
本文介绍了创建一个没有边框的自定义部分半透明表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅我的原始项目以查看背景: 在C#中作为初学者创建NFO查看器 [ ^ ]



我''为它创造了很多设计,最近我想尝试一些部分半透明的应用程序。这个想法如下图所示:

http://img341.imageshack.us/img341/5402/policetesttransparency.png

在这种情况下,我创建了2个表单,1 100%可见所有控件和图像的半透明部分的额外形式。因此我想要使用的图像在导入之前也必须分成两部分。在正确的位置导入和加载后,我必须创建将同时移动两个表单的代码。我通过使用mousemove方法移动form1后为form2添加''newlocation''来做到这一点。



我遇到的问题

移动并非恰好在同一时间,有一些延迟,导致两个图片部分之间出现间隙...

当我想使用第二个表单移动我的应用程序时,它不会工作(激活第二个表单焦点)。因为它可以覆盖主窗体,所以我必须设置alwaysontop,所以我不能把任何其他应用程序放在它前面。

我想让它像一个窗体一样工作。



我尝试使用GIMP创建部分半透明图像,将其导出为png或gif。但是很难保持透明度,我无法在Visual Studio中导入它(透明度消失了)。



有没有办法导入部分透明以某种方式在Winforms中的图像?

或者是否有一些方法可以改进组合2个表格以制作1张图片的方式?

任何建议都会受到欢迎,这是第一次我尝试这样的东西,我几乎让它工作,但它对我来说不太实用。



事先谢谢!

解决方案

使表格透明而不是你做的控制

你可以轻松地使用1表格 -

< pre lang =c#> BackColor = Color.Blue;
TransparencyKey = Color.Blue;



在你的Form_Load中使用它

蓝色的一切都是透明的。



如果您需要删除表单的边框



 FormBorderStyle = FormBorderStyle .None; 


http://stackoverflow.com/questions/395256/transparent-images-with-c-sharp-winforms



- 阅读答案6



透明图像控制







http:/ /stackoverflow.com/questions/5522337/c-sharp-picturebox-transparent-background-doesnt-seem-to-work


Refer to my original project to see the background: Creating a NFO Viewer in C# as a beginner[^]

I''m creating a lot of designs for it and lately I wanted to try some applications which are partly semi-transparent. The idea is as the following image shows:
http://img341.imageshack.us/img341/5402/policetesttransparency.png
In this case I''ve created 2 forms, 1 100% visible with all controls and an extra form for the semi-transparant part of the image. So the image I want to use, also has to be split in 2 parts before I import it. After importing and loading on right place, I had to create code that will move both forms at same time. I''ve done this by adding the ''newlocation'' for form2 after moving form1 in with the mousemove method.

Problems I have with this one:
Moving isn''t precisely at same time, there''s some latency, which causes gaps to appear between the two picture-parts...
When I want to move my application using the 2nd form, it won''t work (activates 2nd form focus). As it could override the main form, I had to set alwaysontop, so I can''t put any other applications in front of it.
I want to have it working like one form.

I tried to create a partly semi-transparant image using GIMP, export it as png or gif. But it''s hard to maintain the transparency and I couldn''t import it in Visual Studio (transparency gone).

Is there some way to import partly transparent images in Winforms somehow?
Or is there some way to improve the way when combining 2 forms to make 1 picture?
Any advise would be welcome, this is the first time I try something like this and I almost got it working, but it''s not very practical for me.

Thanks beforehand!

解决方案

to make the Form transparent and not the Controls you do this
You can use 1 form for all of this - easily.

BackColor = Color.Blue;
TransparencyKey = Color.Blue;


use this in your Form_Load
everything that is blue will be transparent.

if you need to remove the border of your form to

FormBorderStyle = FormBorderStyle.None;


http://stackoverflow.com/questions/395256/transparent-images-with-c-sharp-winforms

- read Answer 6

transparent image control

or

http://stackoverflow.com/questions/5522337/c-sharp-picturebox-transparent-background-doesnt-seem-to-work


这篇关于创建一个没有边框的自定义部分半透明表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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