S
sajin
Hi all,
I implemented the color picker in vb .net 2005 , but i can't select the
color . when ever i move the mose over the sreen or desktop i show the
color below the cusor in the picturebox which is there in the form
But i need is as follows
I will have a pictureBox (like image in the color picker (pen)) i need
to have a drag event , meaning when i drag this image to anywhere and
leave then i should be able to get the color . getting the color is not
a problem , but how to get the event
I am a bigginer
my code is as follows
Public Class Form1
Public Declare Function GetPixel Lib "gdi32.dll" ( _
ByVal hdc As IntPtr, _
ByVal nXPos As Int32, _
ByVal nYPos As Int32 _
) As Int32
Private Declare Function GetDC Lib "user32.dll" ( _
ByVal hWnd As IntPtr _
) As IntPtr
Private Declare Function ReleaseDC Lib "user32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal hdc As IntPtr _
) As Int32
Private m_hdc As IntPtr
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
m_hdc = GetDC(IntPtr.Zero)
Me.Timer1.Enabled = True
pb.AllowDrop = True
End Sub
Private Sub Form1_Closed( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles MyBase.Closed
ReleaseDC(IntPtr.Zero, m_hdc)
End Sub
Private Sub Timer1_Tick( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles Timer1.Tick
Me.PictureBox1.BackColor = _
ColorTranslator.FromWin32( _
GetPixel(m_hdc, Windows.Forms.Cursor.Position.X,
Windows.Forms.Cursor.Position.Y) _
)
End Sub
End Class
I tried with drag events...but not working , i am not sure how to use
that
Thanks
Sajin
I implemented the color picker in vb .net 2005 , but i can't select the
color . when ever i move the mose over the sreen or desktop i show the
color below the cusor in the picturebox which is there in the form
But i need is as follows
I will have a pictureBox (like image in the color picker (pen)) i need
to have a drag event , meaning when i drag this image to anywhere and
leave then i should be able to get the color . getting the color is not
a problem , but how to get the event
I am a bigginer
my code is as follows
Public Class Form1
Public Declare Function GetPixel Lib "gdi32.dll" ( _
ByVal hdc As IntPtr, _
ByVal nXPos As Int32, _
ByVal nYPos As Int32 _
) As Int32
Private Declare Function GetDC Lib "user32.dll" ( _
ByVal hWnd As IntPtr _
) As IntPtr
Private Declare Function ReleaseDC Lib "user32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal hdc As IntPtr _
) As Int32
Private m_hdc As IntPtr
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
m_hdc = GetDC(IntPtr.Zero)
Me.Timer1.Enabled = True
pb.AllowDrop = True
End Sub
Private Sub Form1_Closed( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles MyBase.Closed
ReleaseDC(IntPtr.Zero, m_hdc)
End Sub
Private Sub Timer1_Tick( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles Timer1.Tick
Me.PictureBox1.BackColor = _
ColorTranslator.FromWin32( _
GetPixel(m_hdc, Windows.Forms.Cursor.Position.X,
Windows.Forms.Cursor.Position.Y) _
)
End Sub
End Class
I tried with drag events...but not working , i am not sure how to use
that
Thanks
Sajin