تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] جعل خلفية اداة RichTextBox صورة
#1
Information 
شباب اريد جعل  اداة RichTextBox صورة
ضرورى
المطلوب بالتفصيل ان يكون لدي اداة RichTextBox  خلفية بمعنى ان يكون ظاهر خلف النص صورة 
Huh Huh Huh Huh
الرد }}}
تم الشكر بواسطة:
#2
جرب اضافة كلاس
كود :
Public Class OpaqueRichTextBox
   Inherits RichTextBox

   Private Shared ReadOnly DefaultBackground As Color = Color.Transparent
   Private TransparentImage As Image

   Public Sub New()
       Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
       Me.SetStyle(ControlStyles.Opaque, True)
       Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True)
       BackColor = DefaultBackground
   End Sub

   Public Overrides Property BackColor() As System.Drawing.Color
       Get
           Return MyBase.BackColor
       End Get
       Set(ByVal value As System.Drawing.Color)
           MyBase.BackColor = value
       End Set
   End Property

   Public Property Image() As Image
       Get
           Return TransparentImage
       End Get
       Set(ByVal value As Image)
           TransparentImage = value
           Invalidate()
       End Set
   End Property

   Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
       Get
           Dim cp As CreateParams = MyBase.CreateParams
           cp.ExStyle = cp.ExStyle Or &H20
           Return cp
       End Get
   End Property

   ' Infrastructure to cause the default background to be transparent
   Public Function ShouldSerializeBackColor() As Boolean
       Return BackColor = DefaultBackground
   End Function

   ' Infrastructure to cause the default background to be transparent
   Public Sub ResetBackground()
       BackColor = DefaultBackground
   End Sub

End Class


ووضع الصورة خلف التيكست
الرد }}}
تم الشكر بواسطة: سعود
#3
(28-10-15, 11:23 PM)HASAN6.0 كتب : جرب اضافة كلاس
كود :
Public Class OpaqueRichTextBox
   Inherits RichTextBox

   Private Shared ReadOnly DefaultBackground As Color = Color.Transparent
   Private TransparentImage As Image

   Public Sub New()
       Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
       Me.SetStyle(ControlStyles.Opaque, True)
       Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True)
       BackColor = DefaultBackground
   End Sub

   Public Overrides Property BackColor() As System.Drawing.Color
       Get
           Return MyBase.BackColor
       End Get
       Set(ByVal value As System.Drawing.Color)
           MyBase.BackColor = value
       End Set
   End Property

   Public Property Image() As Image
       Get
           Return TransparentImage
       End Get
       Set(ByVal value As Image)
           TransparentImage = value
           Invalidate()
       End Set
   End Property

   Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
       Get
           Dim cp As CreateParams = MyBase.CreateParams
           cp.ExStyle = cp.ExStyle Or &H20
           Return cp
       End Get
   End Property

   ' Infrastructure to cause the default background to be transparent
   Public Function ShouldSerializeBackColor() As Boolean
       Return BackColor = DefaultBackground
   End Function

   ' Infrastructure to cause the default background to be transparent
   Public Sub ResetBackground()
       BackColor = DefaultBackground
   End Sub

End Class


ووضع الصورة خلف التيكست

شكرا اخى
ولكن الكود به مشكلة  Sad
الرد }}}
تم الشكر بواسطة:
#4
أنصحك أن لا تستخدم هذا الاسلوب خاصة أن التغيير في مثل هذه الانواع من الكونترول باستخدام الجرافكس له مشاكل لا حصر لها و هذا ما جعل مايكروسوفت تصمم الكونترول بمثل هذه الطريقة أصلا
الرد }}}
تم الشكر بواسطة: سعود , mina250



التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم