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

How To Move Object ?

بدأه kazabra في 21 مايو 2009 · 4 رد · 510 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

How To Move Object By Mouse at Run Time ?

#2
Public Class Form1

	Dim cx, cy As Integer
	Dim isMoving As Boolean

	Private Sub Label1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown
		If e.Button = Windows.Forms.MouseButtons.Left Then
			cx = e.X
			cy = e.Y
			isMoving = True
		End If
	End Sub

	Private Sub Label1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseMove
		If isMoving Then
			Label1.Location = New Point(Label1.Location.X + (e.X - cx), Label1.Location.Y + (e.Y - cy))
		End If
	End Sub

	Private Sub Label1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseUp
		isMoving = False
	End Sub
End Class

إن قلت قال الله قال رسولـه همزوك همز المنكر المتعالي
أو قلت قد قال الصحابة والألـى تبعاً لهم بالقول والأعمال
أو قلت قـال الشافعي وأحمد و أبو حنيفة والإمام الغالي
صدوا عن وحي الإله ودينـه واحتالوا على حرام الله بالإحلال
يا أمةً لعبت بدين نبيها كتلاعب الصبيان في الأوحال
حاشا رسول الله يحكم بالهوى تلك إذاً حكومة الضلال

feed.1.gif

#3

Thx Ghost that what i Talking about

100 Thx Man

Did u Know How To Make Label Or Panael Transparent [Opacity ]

#4

Hi Kazabra,

You can something similar :

 

[color= #000000; font-weight: bold;]Public [color= #000000; font-weight: bold;]Class Form1

[color= #000000; font-weight: bold;]Private WithEvents Label1[color= #339933;], Label2 [color= #b1b100;]As [color= #000000; font-weight: bold;]New Label

 

 

[color= #000000; font-weight: bold;]Private Sub Labels_MouseDown[color= #009900;](ByVal Sender [color= #b1b100;]As Object[color= #339933;], [color= #990000;]_

ByVal E [color= #b1b100;]As [color= #990000;]System[color= #339933;].Windows[color= #339933;].Forms[color= #339933;].MouseEventArgs[color= #009900;]) Handles Label1[color= #339933;].MouseDown[color= #339933;], Label2[color= #339933;].MouseDown

Sender[color= #339933;].Tag [color= #339933;]= [color= #000000; font-weight: bold;]New Point[color= #009900;](E[color= #339933;].X[color= #339933;], E[color= #339933;].Y[color= #009900;])

[color= #990000;]End Sub

 

 

 

[color= #000000; font-weight: bold;]Private Sub Labels_MouseMove[color= #009900;](ByVal Sender [color= #b1b100;]As Object[color= #339933;], [color= #990000;]_

ByVal E [color= #b1b100;]As [color= #990000;]System[color= #339933;].Windows[color= #339933;].Forms[color= #339933;].MouseEventArgs[color= #009900;]) Handles Label1[color= #339933;].MouseMove[color= #339933;], Label2[color= #339933;].MouseMove

[color= #b1b100;]If Sender[color= #339933;].Tag Is Nothing Then [color= #990000;]Exit Sub

[color= #b1b100;]If E[color= #339933;].Button [color= #339933;]= Windows[color= #339933;].Forms[color= #339933;].MouseButtons[color= #339933;].Left Then

Dim Pt [color= #b1b100;]As Point [color= #339933;]= CType[color= #009900;](Sender[color= #339933;].Tag[color= #339933;], Point[color= #009900;])

Sender[color= #339933;].Left [color= #339933;]+= [color= #009900;](E[color= #339933;].X [color= #339933;]- Pt[color= #339933;].X[color= #009900;])

Sender[color= #339933;].Top [color= #339933;]+= [color= #009900;](E[color= #339933;].Y [color= #339933;]- Pt[color= #339933;].Y[color= #009900;])

[color= #990000;]End [color= #b1b100;]If

[color= #990000;]End Sub

 

[color= #990000;]End [color= #000000; font-weight: bold;]Class

For the transparent issue, Try to change the alpha value of the panel back color, like :

 

[color= #000000; font-weight: bold;]Private Sub SetTrans[color= #009900;](Byval Con [color= #b1b100;]As Control[color= #339933;], Byval Alpha [color= #b1b100;]As Byte[color= #009900;])

Dim CO [color= #b1b100;]As Color [color= #339933;]= Con[color= #339933;].BackColor

Con[color= #339933;].BackColor [color= #339933;]= Color[color= #339933;].FromArgb[color= #009900;]( Alpha[color= #339933;], CO[color= #339933;].R[color= #339933;], CO[color= #339933;].G[color= #339933;], CO[color= #339933;].B [color= #009900;])

[color= #990000;]End Sub

 

Usage [color= #339933;]:

SetTrans[color= #009900;]( Panel1[color= #339933;], [color= #cc66cc;]50 [color= #009900;])

Good luck

تم تعديل هذه المشاركة بواسطة Bashar Rabat في 21 مايو 2009 في 23:51

The important thing is not so much

that every child should be taught,

as that every child should be given the wish to learn.

#5

Thx Bashar

But about Transparent Issue Doesn't Work I Don't why Cause All People Told Me , To Use Color.FromArgb But It Doesn't Work

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