انا عايز الفورم يظلل فورم اخر وليش شاشة الكمبيوتر
استخدمت الكود التالي ولكن لاينطبق الفورم يظهر مظلل بالحجم والابعاد التي اريدها ولكن الفورم لاينطبق عل الاخر
Dim plexi = New Form()
plexi.FormBorderStyle = FormBorderStyle.None
plexi.Size = New Size(Me.Width, Me.Height - 30)
plexi.StartPosition = FormStartPosition.CenterParent
plexi.AutoScaleMode = AutoScaleMode.None
plexi.ShowInTaskbar = False
plexi.BackColor = Color.Black
plexi.Opacity = 0.45
plexi.Location = New Point(Me.Left, Me.Top - 30)
plexi.Show()
01-12-17, 10:47 AM (آخر تعديل لهذه المشاركة : 01-12-17, 10:57 AM {2} بواسطة silverlight.)
أضف الكلاس التالي الي مشروعك
وهو سيعمل بمثابة DarkForm
أنا فقط أعطيته اسما أخر هو BlendForm
PHP كود :
Public Class BlendForm Inherits Form
Public Sub New(rect As Rectangle, colorBack As Color, alpha As Byte) MyBase.StartPosition = FormStartPosition.Manual MyBase.FormBorderStyle = FormBorderStyle.None MyBase.TopLevel = True MyBase.TopMost = True MyBase.ShowInTaskbar = False MyBase.ShowIcon = False MyBase.BackColor = colorBack Me.DoubleBuffered = True Me.Opacity = GetOpacity(alpha, MyBase.BackColor) Me.Bounds = rect End Sub
Friend Function GetOpacity(sca As Byte, sourceColor As Color) As Double sca = Byte.MaxValue - sca Dim dest As Color = Color.FromArgb(CInt((1 - (sca / Byte.MaxValue)) * Byte.MaxValue), sourceColor) Return CDbl(CByte(If(dest.A > 255, 255, If(dest.A < 0, 0, dest.A))) / Byte.MaxValue) End Function
End Class
الكود التالي يوضح لك كيفية حساب مكان الفورم الرئيسي علي شاشة الكمبيوتر
ومن ثم نقوم بإظهار BlendForm فوقه تماما
PHP كود :
Public Class Form1
Private blend As BlendForm
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ShowBlendForm() End Sub
Private Sub ShowBlendForm() Dim rect As Rectangle = GetWindowBounds(Me.Bounds) rect.X = rect.X + (2 * SystemInformation.FrameBorderSize.Width) rect.Width = rect.Width - (4 * SystemInformation.FrameBorderSize.Width) rect.Height = rect.Height - (2 * SystemInformation.FrameBorderSize.Height) Dim alpha As Byte = 128 Dim blendColor As Color = Color.Blue blend = New BlendForm(rect, blendColor, alpha) blend.Show() End Sub
Friend Function GetWindowBounds(ByRef rect As Rectangle) As Rectangle Dim scrBounds As Rectangle = SystemInformation.VirtualScreen Dim topleft As Point = New Point(Math.Max(rect.Left, scrBounds.X), Math.Max(rect.Top, scrBounds.Y)) Dim bottomRight As Point = New Point(Math.Min(rect.Right, scrBounds.X + scrBounds.Width), Math.Min(rect.Bottom, scrBounds.Y + scrBounds.Height)) rect.Location = topleft rect.Height = Math.Abs(bottomRight.Y - rect.Top) rect.Width = Math.Abs(bottomRight.X - rect.Left) Return rect End Function
End Class
ملحوظة أخيرة
الفورم غالبا يرسم نفسه بطرق مختلفة حسب نظام التشغيل
مثلا الحسابات اعلاه صالحة للويندوز 10 بشرظ أن الفورم الرئيسي يكون Sizable
و غالبا إن الأفضل أنك تستغني عن الأسطر التالية من الكود
والموجودة في الروتين ShowBlendForm
(01-12-17, 10:47 AM)silverlight كتب : أضف الكلاس التالي الي مشروعك
وهو سيعمل بمثابة DarkForm
أنا فقط أعطيته اسما أخر هو BlendForm
PHP كود :
Public Class BlendForm Inherits Form
Public Sub New(rect As Rectangle, colorBack As Color, alpha As Byte) MyBase.StartPosition = FormStartPosition.Manual MyBase.FormBorderStyle = FormBorderStyle.None MyBase.TopLevel = True MyBase.TopMost = True MyBase.ShowInTaskbar = False MyBase.ShowIcon = False MyBase.BackColor = colorBack Me.DoubleBuffered = True Me.Opacity = GetOpacity(alpha, MyBase.BackColor) Me.Bounds = rect End Sub
Friend Function GetOpacity(sca As Byte, sourceColor As Color) As Double sca = Byte.MaxValue - sca Dim dest As Color = Color.FromArgb(CInt((1 - (sca / Byte.MaxValue)) * Byte.MaxValue), sourceColor) Return CDbl(CByte(If(dest.A > 255, 255, If(dest.A < 0, 0, dest.A))) / Byte.MaxValue) End Function
End Class
الكود التالي يوضح لك كيفية حساب مكان الفورم الرئيسي علي شاشة الكمبيوتر
ومن ثم نقوم بإظهار BlendForm فوقه تماما
PHP كود :
Public Class Form1
Private blend As BlendForm
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ShowBlendForm() End Sub
Private Sub ShowBlendForm() Dim rect As Rectangle = GetWindowBounds(Me.Bounds) rect.X = rect.X + (2 * SystemInformation.FrameBorderSize.Width) rect.Width = rect.Width - (4 * SystemInformation.FrameBorderSize.Width) rect.Height = rect.Height - (2 * SystemInformation.FrameBorderSize.Height) Dim alpha As Byte = 128 Dim blendColor As Color = Color.Blue blend = New BlendForm(rect, blendColor, alpha) blend.Show() End Sub
Friend Function GetWindowBounds(ByRef rect As Rectangle) As Rectangle Dim scrBounds As Rectangle = SystemInformation.VirtualScreen Dim topleft As Point = New Point(Math.Max(rect.Left, scrBounds.X), Math.Max(rect.Top, scrBounds.Y)) Dim bottomRight As Point = New Point(Math.Min(rect.Right, scrBounds.X + scrBounds.Width), Math.Min(rect.Bottom, scrBounds.Y + scrBounds.Height)) rect.Location = topleft rect.Height = Math.Abs(bottomRight.Y - rect.Top) rect.Width = Math.Abs(bottomRight.X - rect.Left) Return rect End Function
End Class
ملحوظة أخيرة
الفورم غالبا يرسم نفسه بطرق مختلفة حسب نظام التشغيل
مثلا الحسابات اعلاه صالحة للويندوز 10 بشرظ أن الفورم الرئيسي يكون Sizable
و غالبا إن الأفضل أنك تستغني عن الأسطر التالية من الكود
والموجودة في الروتين ShowBlendForm