الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

Change Forms Style

مغلق
بدأه A.Samir في 19 سبتمبر 2007 · 7 رد · 1,329 مشاهدة · في Microsoft Visual C#.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

كيف استطيع تغير شكل الForms and Buttons

وهل هناك كتب تعليميه لهذا النوع من البرمجه

ارجوكم ساعدوني انا في حاجه ماسه لها

وشكرا

#2

بالسي شارب لا يوجد

الموضوع موضوع تصميم ازرار controls وليس التحكم بالموجود

ابحث في القوقل عن net controls ,

#3

hi

i'm sorry i can't write in arab and sorry for my bad english too :)))

this is a little sample of a custom button made with vb net 2005 express edition :

the button supports "HOVER" effect with gradient color

just copy the code and paste it in a "class.vb" file or directly as a custom control file

then add it to your project

hope this will give you an idea

YoUsSeF - MAROC

Imports System.ComponentModel

Imports System.Drawing.Drawing2D

Imports System.Drawing

<ToolboxBitmap(GetType(UcfButton), "Icône.bmp"), _

DefaultProperty("caption")> Public Class UcfButton

Inherits Windows.Forms.Button

#Region "declaration"

Private m_MouseOver As Boolean

Private presse As Boolean

Dim DownCouleur As Color = System.Windows.Forms.Control.DefaultBackColor

Dim UpCouleur As Color = System.Windows.Forms.Control.DefaultBackColor

Dim HoverCouleur As Color = System.Windows.Forms.Control.DefaultBackColor

Dim txtCouleur As Color = Color.Black

Dim captionTxt As String = "UCFBouton"

Dim tailleTxt As Integer = 10

Dim Xtxt, Ytxt As Integer 'coordonées du text

#End Region

<Category("UCF SOFT"), Description("Couleur quand le bouton est cliqué")> Property down_color() As Color

Get

Return DownCouleur

End Get

Set(ByVal value As Color)

DownCouleur = value

Invalidate()

End Set

End Property

<Category("UCF SOFT"), Description("Couleur quand le bouton est relaché la meme que la couleur initiale")> Property up_color() As Color

Get

Return UpCouleur

End Get

Set(ByVal value As Color)

UpCouleur = value

Invalidate()

End Set

End Property

<Category("UCF SOFT"), Description("Couleur quand le bouton est survolé")> Property hover_color() As Color

Get

Return HoverCouleur

End Get

Set(ByVal value As Color)

HoverCouleur = value

Invalidate()

End Set

End Property

<Category("UCF SOFT"), Description("Texte du bouton")> Property caption() As String

Get

Return captionTxt

End Get

Set(ByVal value As String)

captionTxt = value

Invalidate()

End Set

End Property

<Category("UCF SOFT"), Description("couleur du Texte du bouton")> Property couleur_texte() As Color

Get

Return txtCouleur

End Get

Set(ByVal value As Color)

txtCouleur = value

Invalidate()

End Set

End Property

<Category("UCF SOFT"), Description("Taille de police du texte bouton")> Property taille_police() As Integer

Get

Return tailleTxt

End Get

Set(ByVal value As Integer)

Try

tailleTxt = value

Catch ex As Exception

MsgBox("une erreur s'est produite :" + ex.Message)

End Try

Invalidate()

End Set

End Property

Protected Overrides Sub OnPaint(ByVal pevent As System.Windows.Forms.PaintEventArgs)

MyBase.OnPaint(pevent)

Dim btxt As New SolidBrush(txtCouleur) 'brush pour la couleur texte

Dim rect As New Rectangle(0, 0, Me.Width, Me.Height)

If m_MouseOver Then

If presse Then

Dim b As New SolidBrush(DownCouleur)

pevent.Graphics.FillRectangle(b, rect)

mesureChaine(pevent, Me.caption)

pevent.Graphics.DrawString(captionTxt, New Font("arial", taille_police), btxt, CType(Xtxt / 2, Single), CType(Ytxt / 2, Single))

Else

Dim myLinearGradientBrush As New LinearGradientBrush(rect, HoverCouleur, UpCouleur, LinearGradientMode.Vertical)

pevent.Graphics.FillRectangle(myLinearGradientBrush, rect)

mesureChaine(pevent, Me.caption)

pevent.Graphics.DrawString(captionTxt, New Font("arial", taille_police), btxt, CType(Xtxt / 2, Single), CType(Ytxt / 2, Single))

End If

Else

Dim myLinearGradientBrush As New LinearGradientBrush(rect, UpCouleur, HoverCouleur, LinearGradientMode.Vertical)

pevent.Graphics.FillRectangle(myLinearGradientBrush, rect)

mesureChaine(pevent, Me.caption)

pevent.Graphics.DrawString(captionTxt, New Font("arial", taille_police), btxt, CType(Xtxt / 2, Single), CType(Ytxt / 2, Single))

End If

Dim rectCadre As New Rectangle(0, 0, Me.Width - 1, Me.Height - 1)

Dim Cadre As New Pen(Color.Black)

pevent.Graphics.DrawRectangle(Cadre, rectCadre)

End Sub

Private Sub hover(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.MouseEnter

m_MouseOver = True

Me.Refresh()

End Sub

Private Sub out(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.MouseLeave

m_MouseOver = False

Me.Refresh()

End Sub

Private Sub down(ByVal sender As Object, ByVal e As Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown

presse = True

Me.Refresh()

End Sub

Private Sub up(ByVal sender As Object, ByVal e As Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp

presse = False

Me.Refresh()

End Sub

Private Sub mesureChaine(ByVal e As System.Windows.Forms.PaintEventArgs, ByVal chaine As String)

Dim measureString As String = chaine

Dim stringFont As Font = New Font("Arial", taille_police)

Dim layoutSize As SizeF = New SizeF(100.0F, 200.0F)

Dim newStringFormat As StringFormat = New StringFormat

newStringFormat.FormatFlags = StringFormatFlags.NoClip

Dim charactersFitted As Integer

Dim linesFilled As Integer

Dim stringSize As SizeF = New SizeF

stringSize = e.Graphics.MeasureString(measureString, stringFont, layoutSize, newStringFormat, charactersFitted, linesFilled)

Dim Wtxt As Integer = CType(stringSize.Width, Integer)

Dim Htxt As Integer = CType(stringSize.Height, Integer)

Xtxt = CType(Me.Width, Integer) - Wtxt

Ytxt = CType(Me.Height, Integer) - Htxt

'liberation memoire

stringFont = Nothing

layoutSize = Nothing

stringSize = Nothing

newStringFormat = Nothing

End Sub

End Class

[code/]

#4

Thanks a lot, But this code in vb.net and I don not know any thing about it I study C# only .

#5

تحياتي

كل ما عليك فعله هو أن تضع الفايل(appface.dll)

في المجلد الذي يوجد فيه الفايل التنفيذي للبرنامج اي داخل (bin\Debug) و من ثم تضع الكود

SkinStart("c:\..........",0,"",1,0,0);

عند كود تشغيل الفورم

اي داخل

public Form1()
{

InitializeComponent();


SkinStart(@"C:\..........",0,"",1,0,0);

}

مع مراعاه مسار الستايل

وهذه الاكواد للاغراض معينة منها تشغيل الستايل وحذف الستايل والى ما هنالك....

المهم ان تضع الدي يهمك داخل كلاس الفورم

        [DllImport("appface.dll")]
        public static extern int SkinStart(string SkinFile, int nDefWinType,string CheckSum, int nType, int hInstance, int nLen);


        [DllImport("appface.dll")]
        public static extern int SkinStartW(string SkinFile, int nDefWinType,string CheckSum, int nType, int hInstance, int nLen);


        [DllImport("appface.dll")]
        public static extern int SkinWindowSet(IntPtr hWnd, int nSkintype);

        [DllImport("appface.dll")]
        public static extern int SkinThread();

        [DllImport("appface.dll")]
        public static extern int SkinRemove();

        [DllImport("appface.dll")]
        public static extern int SkinWindowSetEx(IntPtr hWnd, int nSkintype, int nResourceId,int nUrfLoadType, string SkinFile, int  nce, int nLen);

        [DllImport("appface.dll")]
        public static extern int SkinWindowSetExW(IntPtr hWnd, int nSkintype, int nResourceId,int nUrfLoadType, string SkinFile, int hInstance, int nLen);

وأي مشكلة أنا مستعد للمساعدة

Bissan_sw.rar

#6

في مشكله في ملف ال دي دي ال كل لما اجي اعمل اد ريفرنس يقلي في مشكله ايه العمل

#7
A.Samir كتب:
في مشكله في ملف ال دي دي ال كل لما اجي اعمل اد ريفرنس يقلي في مشكله ايه العمل

أنا ام أقل أن تعمل له اد ريفرينس

كل ما عليك هو وضعه في مسار الفايل التنفيدي البرنامج

تحياتي

#8
bissan_sw كتب:
تحياتي

كل ما عليك فعله هو أن تضع الفايل(appface.dll)

في المجلد الذي يوجد فيه الفايل التنفيذي للبرنامج اي داخل (bin\Debug) و من ثم تضع الكود

SkinStart("c:\..........",0,"",1,0,0);

عند كود تشغيل الفورم

اي داخل

public Form1()
{

InitializeComponent();
SkinStart(@"C:\..........",0,"",1,0,0);

}

مع مراعاه مسار الستايل

وهذه الاكواد للاغراض معينة منها تشغيل الستايل وحذف الستايل والى ما هنالك....

المهم ان تضع الدي يهمك داخل كلاس الفورم

        [DllImport("appface.dll")]
        public static extern int SkinStart(string SkinFile, int nDefWinType,string CheckSum, int nType, int hInstance, int nLen);
        [DllImport("appface.dll")]
        public static extern int SkinStartW(string SkinFile, int nDefWinType,string CheckSum, int nType, int hInstance, int nLen);
        [DllImport("appface.dll")]
        public static extern int SkinWindowSet(IntPtr hWnd, int nSkintype);

        [DllImport("appface.dll")]
        public static extern int SkinThread();

        [DllImport("appface.dll")]
        public static extern int SkinRemove();

        [DllImport("appface.dll")]
        public static extern int SkinWindowSetEx(IntPtr hWnd, int nSkintype, int nResourceId,int nUrfLoadType, string SkinFile, int  nce, int nLen);

        [DllImport("appface.dll")]
        public static extern int SkinWindowSetExW(IntPtr hWnd, int nSkintype, int nResourceId,int nUrfLoadType, string SkinFile, int hInstance, int nLen);

وأي مشكلة أنا مستعد للمساعدة

السلام عليكم

اخي الكريم

جربت كل شي ما يقبل يشتغل ؟؟؟

يقول ذا

SkinStart

ما يعرفه

اش هي المشكله

لو سمحت انو انت تشتغل مثال صغير وترفقه لنا

وبارك الله فيك

هذا الموضوع مغلق.

مواضيع مشابهة