【问题标题】:How to view through C# WinForm from another WinForm如何从另一个 WinForm 中通过 C# WinForm 查看
【发布时间】:2013-04-11 15:26:36
【问题描述】:

我在 C# 中使用 winforms 制作了一个捕获应用程序。 我正在尝试从另一个 winform 中查看一个 winform。

我现在拥有的是:

不透明的黑色背景是winform number 1

带有透明填充的蓝色矩形在winform number 2

我需要一种通过winform 1查看网站页面内容的方法。

这就是我想要完成的:

我已经尝试将填充颜色设置为透明键颜色,如下所示:

这是 1 号 winform 的 TransparencyKey 代码:

this.TransparencyKey = System.Drawing.Color.Pink;

这是在 2 号 winform 上绘制矩形的代码:

SolidBrush TransparentBrush = new SolidBrush(Color.Transparent);
Pen MyPen = new Pen(Color.Blue, 2);

private void ThePaint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            g.FillRectangle(TransparentBrush, CurrentTopLeft.X, CurrentTopLeft.Y, RectangleWidth, RectangleHeight);
            g.DrawRectangle(MyPen, CurrentTopLeft.X, CurrentTopLeft.Y, RectangleWidth, RectangleHeight);
            RectangleDrawn = true;
        }

【问题讨论】:

  • 我认为你最好使用 WPF。
  • 我希望!,但我不能为此使用 WPF。
  • 1.它已经完成了。 2.我是从Winforms开始才知道WPF的

标签: c# winforms


【解决方案1】:

您可以尝试在表单 2 上放置一个面板,然后将其颜色设置为“粉红色” - 这样,它会通过表单 2 透明到后面的网页。唯一的缺点是,如果你有任何控件,它看起来确实很奇怪。这一切都可以通过 WinForm 设计器实现。

【讨论】:

  • "that way, it will be transparent through the form 2 to the web page behind." 你的意思是从 1 开始吗?因为我需要它才能看穿黑色不透明的winform
  • 不用担心 - 很高兴它有帮助!抱歉,我不打算回复您的评论。
猜你喜欢
  • 2019-10-30
  • 1970-01-01
  • 1970-01-01
  • 2017-01-16
  • 1970-01-01
  • 2012-10-25
  • 1970-01-01
  • 1970-01-01
  • 2015-01-20
相关资源
最近更新 更多