0
我想要使面板控件和其中的控件/對象漸變效果。我發現一些具有不透明屬性的容器只會改變背景顏色的不透明度。VB.NET |如何獲得Windows窗體WorkingArea,而不是桌面WorkingArea
所以我想出了我自己的解決方案。我創建了另一個包含我需要的控件的表單,並且獲得了我想要的,但是在定位創建的新表單時遇到了一些問題。我不知道如何獲得其父母的工作領域來確定初始職位。我指的是工作區域,它不包括控制框/標題欄。不同的操作系統有不同的標題欄尺寸(據我所知),所以我需要調整它正確
窗體2時,一個拿着不透明控制
Public Class Form2
Private Const dif As Integer = 23
Private Const GWL_EXSTYLE As Integer = (-20)
Private Const WS_EX_TRANSPARENT As Integer = &H20
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As IntPtr, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As IntPtr, ByVal nIndex As Integer) As Integer
Public Sub resizeFrom(ByVal parent As Form)
Me.Height = parent.Height - dif
Me.Width = parent.Width
Me.Top = (parent.Top + ((parent.Height - Me.Height)/2) + (dif/2))
Me.Left = parent.Left + ((parent.Width - Me.Width)/2)
End Sub
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.TopMost = True
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.BackColor = Color.Red
SetWindowLong(Me.Handle, GWL_EXSTYLE, GetWindowLong(Me.Handle, GWL_EXSTYLE) Or WS_EX_TRANSPARENT)
End Sub
End Class
的父/主窗體
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Show()
Form2.Show()
Form2.resizeFrom(Me)
End Sub
Private Sub Form1_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Move
Form2.resizeFrom(Me)
End Sub
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
Form1_Move(Me, New EventArgs)
End Sub
Private Sub HScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar1.Scroll
Form2.Opacity = HScrollBar1.Value/100
Me.Text = "Opacity: " & HScrollBar1.Value & "%"
End Sub
End Class
它應該是這樣的 http://i48.tinypic.com/25qubk0.jpg
不透明形式是用於顯示目的,它被設置爲「鬼像表」或「點擊救援人員到場呃表格「
是否有任何解決方案,以便我可以得到表格的正確WorkingArea?
請幫忙。 謝謝
不清楚me.in排序你想要什麼? – Arpit
我需要表單的WorkingArea。 WorkingArea僅適用於Desktop,它不包含任務欄。與我需要的一樣,但不包含標題欄。 – pvzkch