dark form - محمد اسماعيل - 29-11-17
السلام عليكم
عندي 3 فورم فورم رئيسي وفورم تظليل وفورم اخر
الفورم الثالث عند فتحة يجعل الفورم الثاني شفاف للفورم الرئيسي
قمت بعمل الفورم الثاني شفاف وتغير درجة الشفافية كل شيء تمام بس لما بيظهر الفورم الثالث الثاني الشفاف يظهر بعيدا عن الفورم الرئيسي ولا ينطبق علية
قمت بعمل فورم التظليل الشفاف center parent
ولكن يظهر في مكان خلاف الفورم الرئيسي
اريد ان ينطبق علي الفورم الرئيسي ويكون الفورم الثالث center parent
طبعا مش هينفع اعمل الفورم الفورم الثاني show dialog عشان اظهر الفورم الثالث
RE: dark form - silverlight - 29-11-17
حاول تضع مثال يعبر عن الفكرة التي تتحدث عنها
RE: dark form - ﻣﺒﺘﺪﺉ - 30-11-17
وعليكم السلام
ممكن يكون هذا الموضوع نفس المطلوب لان فيه مرفق باسم DarkenForm.zip
http://vb4arb.com/vb/showthread.php?tid=7969
RE: dark form - محمد اسماعيل - 30-11-17
(30-11-17, 03:31 PM)ﻣﺒﺘﺪﺉ كتب : وعليكم السلام
ممكن يكون هذا الموضوع نفس المطلوب لان فيه مرفق باسم DarkenForm.zip
http://vb4arb.com/vb/showthread.php?tid=7969
هذا هو طلبي لكن الروابط كلها لاتعمل
RE: dark form - محمد اسماعيل - 30-11-17
(30-11-17, 06:51 PM)Amir_alzubidy كتب : السلام عليكم و رحمة الله
هذا مثال :
انا عايز الفورم يظلل فورم اخر وليش شاشة الكمبيوتر
استخدمت الكود التالي ولكن لاينطبق الفورم يظهر مظلل بالحجم والابعاد التي اريدها ولكن الفورم لاينطبق عل الاخر
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()
RE: dark form - ﻣﺒﺘﺪﺉ - 01-12-17
يا ليت الادارة تعيد تحديث المرفق DarkenForm.zip في الرابط
http://vb4arb.com/vb/showthread.php?tid=7969
RE: dark form - silverlight - 01-12-17
أضف الكلاس التالي الي مشروعك
وهو سيعمل بمثابة 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
PHP كود :
rect.X = rect.X + (2 * SystemInformation.FrameBorderSize.Width) rect.Width = rect.Width - (4 * SystemInformation.FrameBorderSize.Width) rect.Height = rect.Height - (2 * SystemInformation.FrameBorderSize.Height)
RE: dark form - محمد اسماعيل - 01-12-17
(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
PHP كود :
rect.X = rect.X + (2 * SystemInformation.FrameBorderSize.Width) rect.Width = rect.Width - (4 * SystemInformation.FrameBorderSize.Width) rect.Height = rect.Height - (2 * SystemInformation.FrameBorderSize.Height)
الف شكر علي ردك انا عدلت الكود الي في اول الخاص بالاستاذ Amir_alzubidy وظبط معايا بس في مشكلة اخري وايضا نفس المشكلة بالكودد الخاص بك
المشكلة انة عند الضغط علي ايقونة الفورم الرئيسي بسطح المكتب الفورم المظلل يظهر خلف الفورم الرئيسي
PHP كود :
Dim dark = New Form() dark.FormBorderStyle = FormBorderStyle.None dark.Size = New Size(Me.Width, Me.Height) dark.StartPosition = FormStartPosition.Manual dark.AutoScaleMode = AutoScaleMode.None dark.ShowInTaskbar = False dark.TopMost = True dark.BackColor = Color.Black dark.Opacity = 0.45 dark.Location = New Point(Me.Left, Me.Top) dark.Show()
RE: dark form - HASAN6.0 - 01-12-17
http://vb4arb.com/vb/showthread.php?tid=13763
RE: dark form - silverlight - 01-12-17
ما فهمته من سؤالك أنك لديك عدد 2 فورم
وتريد عندما يظهر الفورم الثاني
تقوم بتظليل الفورم الرئيسي
عموما الأكواد اعلاه مجرد مرجع لك لتنفيذ فكرتك
في المرفقات ستجد تفاصيل أكثر
انظر المرفقات
|