使pictureBox透明MDI格式 - VB.Net [英] Make pictureBox Transparent over MDI form - VB.Net

查看:96
本文介绍了使pictureBox透明MDI格式 - VB.Net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的家伙,今天的问题是这样的:

我有一个显然包含所有其他表格的MDI表格。

在我程序的主菜单上(在MDI表格上),我想要放置4个pictureBox。

现在,mdi的BackgroundImage没有设置为none,我正在加载我自己的图片并拉伸它。图片框backColor设置为透明。当我运行代码,而不是在pictureBox上的透明背景,我可以看到mdi的BackgroundImage,我只能看到白色背景(或灰色)。任何想法?

谢谢,

oron。

解决方案

我想这是关于理解还是透明度 。在原始效果中,没有任何东西是透明的:对于不同的像素,你只有不同的颜色,并且像素总是100%不透明。

当你移动时,透明效果会出现(而不是隐喻)一些对象超过非均匀背景。然后背景表现为一些透视图案;结果像素由背景和前景的颜色组合而成。在统一的背景下,透明度是不可检测的。没有办法发现半透明图像之间的差异,或者根据一些不透明度值以一定比例着色的背景颜色的100%不透明图像。



现在:两个建议可能会出乎意料:

  • 几乎从不使用 PictureBox 。除了最简单的情况外,这种控制完全是多余的,不会给你带来任何好处(但可能会增加许多麻烦)。透明度已经不是一个简单的案例。而是在自己的某些 Control 上渲染一些 Image 。显示一些半透明图像非常简单。


  • 永远不要使用MDI。不要折磨自己,吓跑你的顾客。您将在下面引用的一些过去的答案中看到我建议做的事情。




对我过去答案的一些参考:

在图片框中附加图片 [ ^ ],

在C#中绘制一个矩形 [ ^ ],

如何清除来自旧图纸的面板 [ ^ ],

什么样的俏皮方法是Paint? (DataGridViewImageCell.Paint(...)) [ ^ ],

在面板上捕获绘图 [ ^ ],

mdi子表单之间的绘制线 [ ^ ],

如何在WPF中创建MDI父窗口? [解决方案2 ],

关于在WPF中使用MDI窗口的问题 [ ^ ],

麦当劳给出错误 [ ^ ],

如何设置子表单最大化,最后一个子表单最小化 [ ^ ]。



祝你好运。

-SA

o.k guys, the problem today goes like this:
I have an MDI form which contains all the other forms obviously.
on the main menu of my program (on the MDI form), i want to lay 4 pictureBox's.
Now, the BackgroundImage of the mdi is NOT set to none and i am loading my own picture and stretch it. the picturebox backColor is set to Transparent. when i run the code, instead of transparent Background on the pictureBox where i can see the BackgroundImage of the mdi, all i can see is white Background (or Gray). any ideas?
thanks,
oron.

解决方案

I guess this is about understanding or "transparency". In raw effect, nothing is transparent: you just have different colors for different pixels, and the pixel is always 100% opaque.
The effect of transparency comes up (rather as a metaphor), when you move some object over non-uniform background. Then the background behave as some see-through pattern; the resulting pixels are composed of the combination of colors of background and foreground. On a uniform background, "transparency" is undetectable. There is no a way to spot the difference between the semi-transparent image, or some 100% opaque image tinted with the background color in certain proportion depending on some opaqueness value.

Now: two recommendations which may come at surprise:
  • Almost never use PictureBox. This control is totally redundant and won't give you any benefits (but may add a lot of troubles), except the simplest possible cases. Transparency is already not the simple case. Instead, render some Image on some Control yourself. Showing some semi-transparent image is quite trivial.

  • Never use MDI. Don't torture yourself and scare off you customers. You will see what I recommend to do in some of the past answers referenced below.


Some references to my past answers:
Append a picture within picturebox[^],
draw a rectangle in C#[^],
How do I clear a panel from old drawing[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^],
capture the drawing on a panel[^],
Drawing Lines between mdi child forms[^],
How to Create MDI Parent Window in WPF? [Solution 2],
Question on using MDI windows in WPF[^],
MDIContainer giving error[^],
How to set child forms maximized, last childform minimized[^].

Good luck.
—SA


这篇关于使pictureBox透明MDI格式 - VB.Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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