Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Alex Kon  
#1 Posted : Thursday, November 8, 2007 6:28:48 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups: Member
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
This is reincarnation of Color Picker Sample from Graphics Mill ActiveX forum. The essential code is listed below, full project can be found in attachments.
Code:
Public Class Form1
    Private _screenGraphics As Aurigma.GraphicsMill.Drawing.GdiGraphics
    Private _capturing As Boolean

    Private Declare Function SetCapture Lib "user32" (ByVal hwnd As IntPtr) As Long
    Private Declare Function ReleaseCapture Lib "user32" () As Long

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        _screenGraphics = Aurigma.GraphicsMill.Drawing.GdiGraphics.FromHwnd(IntPtr.Zero)
    End Sub


    Private Sub _pickButton_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles _pickButton.MouseDown
        SetCapture(_pickButton.Handle)
        Me.Cursor = System.Windows.Forms.Cursors.Help
        _capturing = True
    End Sub


    Private Sub _pickButton_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles _pickButton.MouseUp
        ReleaseCapture()
        Me.Cursor = System.Windows.Forms.Cursors.Default
        _capturing = False
    End Sub


    Private Sub _pickButton_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles _pickButton.MouseMove
        If _capturing Then
            Dim screenPoint As System.Drawing.Point = _pickButton.PointToScreen(e.Location)
            _coordsTextBox.Text = String.Format("X: {0} Y: {1}", screenPoint.X, screenPoint.Y)

            Dim color As System.Drawing.Color = _screenGraphics.GetPixel(screenPoint.X, screenPoint.Y)
            _colorPanel.BackColor = color
            _colorTextBox.Text = color.ToString()
        End If
    End Sub
End Class

Feel free to ask if you have any questions or discuss the posted code. If you need C# version - do not hesitate to contact us, we surely will provide it.

Edited by moderator Monday, May 28, 2012 8:46:30 PM(UTC)  | Reason: Not specified

File Attachment(s):
ColorPickerSample.zip (1,379kb) downloaded 65 time(s).
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.