تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[كود] تعديل Control.WndProc Method
#1
vb.net كود
كود :
Sub CustomPaint()
        CreateGraphics.DrawRectangle(New Pen(Color.FromArgb(0, 0, 0)), New Rectangle(1, 1, Width - 3, Height - 3))
        CreateGraphics.DrawRectangle(New Pen(Color.FromArgb(90, 90, 90)), New Rectangle(0, 0, Width - 1, Height - 1))
    End Sub
C# يوجد خطأ
كود :
public void CustomPaint()
{
    CreateGraphics.DrawRectangle(new Pen(Color.FromArgb(0, 0, 0)), new Rectangle(1, 1, Width - 3, Height - 3));
    CreateGraphics.DrawRectangle(new Pen(Color.FromArgb(90, 90, 90)), new Rectangle(0, 0, Width - 1, Height - 1));
}
الخطأ فى
CreateGraphics.DrawRectangle(new Pen(Color.FromArgb(0, 0, 0)), new Rectangle(1, 1, Width - 3, Height - 3));
CreateGraphics.DrawRectangle(new Pen(Color.FromArgb(90, 90, 90)), new Rectangle(0, 0, Width - 1, Height - 1));
vb.net

كود :
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        MyBase.WndProc(m)
        If m.Msg = 15 Then CustomPaint()
    End Sub
C#
كود :
protected override void WndProc(ref System.Windows.Forms.Message m)
    {
        base.WndProc(m);
        if (m.Msg == 15)
        {
            CustomPaint();
        }
    }
الخطأ فى base.WndProc(m);
الرد }}}
تم الشكر بواسطة:
#2
شكرآ اخى base.WndProc(ref m); يعمل الان لكن

e.Graphics لايمكن أستخدامها
the name 'e does not exist in the current context
الرد }}}
تم الشكر بواسطة:
#3
.....

راجع الرابط التالي (Control.CreateGraphics Method)

بالنسبة لـ WndProc راجع الموضوع التالي (Control.WndProc Method)
يجب التحديد بـ ref للمتغير m
كود :
base.WndProc(ref m);

.....
الرد }}}
تم الشكر بواسطة:
#4
شكرآ اخى تم حل المشكلة
سؤال كيف يممكننى ان اتحكم فى Listbox من Form مختلف جربت الكثير من الاكواد ولم تنجح!
الرد }}}
تم الشكر بواسطة:
#5
.....

. لم أفهم فكرة مشروعك،
. مالذي صعب عليك في ListBox
. وماذا تقصد بـ Form مختلف
؟!

.....
الرد }}}
تم الشكر بواسطة:
#6
اقصد لو يوجد 2 Form فى Form 2 يوجد ListBox فه يمكن التحكم فى هذه ListBox من Form1 مثلآ اضافه Item او مسح الخخخخخخخخ
الرد }}}
تم الشكر بواسطة:
#7
.....

للتحكم في أدوات Form2عن طريق Form1 في لغة #Visual C يجب أولا تحديد تلك الأدوات في الـ Form2 وتغيير قيمة الخاصية Modified لكل أداة إلى Public

كود :
// Form1

Form2 frm2 = new Form2();

private void button1_Click(object sender, EventArgs e) {
    frm2.listBox1.Items.Add("aaaa");
    frm2.Show();
}

.....
الرد }}}
تم الشكر بواسطة:



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


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