以两种不同的不透明度显示表单

发布于 2024-11-29 13:08:59 字数 712 浏览 0 评论 0原文

我的情况是这样的。

我有一个名为 frmPopup 的表单,其中有一个名为 pnlCtrlHolder 的面板。我将使用此表单作为弹出窗口,并在该面板中显示第三个表单作为控件。

在表格 X 上。

dim frm as frmPopup
''Set the properties for this frmPopup
frm.Opacity=60

Dim frmContent as frmContent
''Set the properties for this frmPopup
frm.Opacity=100

frm.SetForm(frmContent)
frm.ShowDialog(me.toplevelControl)

在 frmPopup 中:

Public Sub SetForm(frm as Windows.Forms.Form)
pnlCtrlHolder.Controls.Clear()
pnlCtrlHolder.Controls.add(frm)
End Sub

现在是我的问题, 这使得整个表单的 frmContent 的不透明度 = 60,但我只需要在 frmPopup 上使用它,而不是在 frmContent 上。

我正在开发 vb.net Winforms 应用程序。我知道我正在添加一个表单作为不透明度为 60 的表单的控件。但是有什么方法可以达到预期的结果。 。我错过了什么吗?

My situation is something like this.

I have a form as frmPopup which has a panel as pnlCtrlHolder. I'll using this form a popup and display a third form as control in this panel.

on form X.

dim frm as frmPopup
''Set the properties for this frmPopup
frm.Opacity=60

Dim frmContent as frmContent
''Set the properties for this frmPopup
frm.Opacity=100

frm.SetForm(frmContent)
frm.ShowDialog(me.toplevelControl)

In frmPopup:

Public Sub SetForm(frm as Windows.Forms.Form)
pnlCtrlHolder.Controls.Clear()
pnlCtrlHolder.Controls.add(frm)
End Sub

Now my problem,
This makes entire form with frmContent with opacity =60, but I need this only on frmPopup but not on frmContent.

I am working on vb.net Winforms application. I understand that I am adding a form as control on a form with opacity as 60. But is there any way to achieve the desired result. . Am i missing something?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

靖瑶 2024-12-06 13:08:59

怎么样:

dim frm as New frmPopup   
frm.Opacity=60
Dim frmContent as New frmContent
frmContent.Opacity=100

How about:

dim frm as New frmPopup   
frm.Opacity=60
Dim frmContent as New frmContent
frmContent.Opacity=100
情愿 2024-12-06 13:08:59

抱歉,我的意思是 OPACITY 是一个介于 0 和 1 之间的值。

我知道这有效,因为我刚刚尝试过。 :-)

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Me.Opacity = 1
        Dim newForm As New Form
        newForm.Text = "NewForm"
        newForm.Opacity = 0.6
        newForm.Show()

    End Sub

End Class

尝试这样的事情:>>

dim frm as New frmPopup   
frm.Opacity=0.6
Dim frmContent as New frmContent
frmContent.Opacity=1

Sorry I meant OPACITY is a value between zero and one.

I know this works as I've just tried it. :-)

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Me.Opacity = 1
        Dim newForm As New Form
        newForm.Text = "NewForm"
        newForm.Opacity = 0.6
        newForm.Show()

    End Sub

End Class

Try something like this:>>

dim frm as New frmPopup   
frm.Opacity=0.6
Dim frmContent as New frmContent
frmContent.Opacity=1
酒几许 2024-12-06 13:08:59

如果您尝试设置放入面板中的表单的不透明度,那么它看起来不会显示,抱歉。

2 个表单一个面板添加到新项目并尝试此操作:>>

Option Strict On
Option Explicit On
Option Infer Off

Public Class Form1

    Public Declare Auto Function SetParent Lib "user32.dll" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
    Friend WithEvents someForm As New Form2

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        someForm.Show()
        someForm.BackColor = Color.White
        someForm.Opacity = 1
        'System.Threading.Thread.Sleep(2000)
        SetParent(someForm.Handle, Panel1.Handle)

    End Sub

End Class

我正在开发 vb.net Winforms 应用程序。我明白我是
在不透明度为60的表单上添加一个表单作为控件。但是有吗
任何方式来达到想要的结果。 。我错过了什么吗?

我什至自己也这样尝试过,没有达到你想要的效果。

Option Strict On
Option Explicit On
Option Infer Off

Public Class Form1

    Friend WithEvents frmPopUp As New Form

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        frmPopUp.Opacity = 0.6
        frmPopUp.TopLevel = False
        frmPopUp.Text = "frmPopUp"
        Me.Controls.Add(frmPopUp)
        frmPopUp.Show()

    End Sub

End Class

If you are trying to set the opacity of a Form that you put in a Panel then it doesn't look like it will show, sorry.

Add 2 Forms and one Panel to a new PROJECT and try this please:>>

Option Strict On
Option Explicit On
Option Infer Off

Public Class Form1

    Public Declare Auto Function SetParent Lib "user32.dll" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
    Friend WithEvents someForm As New Form2

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        someForm.Show()
        someForm.BackColor = Color.White
        someForm.Opacity = 1
        'System.Threading.Thread.Sleep(2000)
        SetParent(someForm.Handle, Panel1.Handle)

    End Sub

End Class

I am working on vb.net Winforms application. I understand that I am
adding a form as control on a form with opacity as 60. But is there
any way to achieve the desired result. . Am i missing something?

I even tried that myself like this without the effect you are after.

Option Strict On
Option Explicit On
Option Infer Off

Public Class Form1

    Friend WithEvents frmPopUp As New Form

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        frmPopUp.Opacity = 0.6
        frmPopUp.TopLevel = False
        frmPopUp.Text = "frmPopUp"
        Me.Controls.Add(frmPopUp)
        frmPopUp.Show()

    End Sub

End Class
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文