Skip to content

[VB2008-10] Color-Picker (How to make one)

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #186874
    ChiNa
    Administrator

    Hello Guys this is my first VB Program, I ever released + the Source Code. (ChiNa-ColorPicker). I am gonna show you how to make one, and I am gonna help you! Here is a tutorial how to make one under 7 Minutes, but I cheated a bit, I had the Source code ready to add.. But anyways, took me to build one in 20 minutes from scratch.. Good Luck!

    PLEASE WATCH THE VIDEO FOR TUTORIAL
    [youtube]vypOqvH19cM[/youtube]

    Example Image from :

    Download the Example I made in video:
    http://www.mediafire.com/?fu5u8pemyjnjey5

    Tutorial:
    Imporatnt to Follow the video, from the start…. And build your “1st Form”, like showen in the video!
    And at last you need to add the SOURCE CODE INSIDE the “2nd Form”! You can also put your own ICON and build it using your own ICON for the EXE file, Good luck guys, if anything, please ask me!

    :::::::::::::: SOURCE CODE IN PARTS :::::::::::::::

    A Section in Form1:
    Private Declare Function GetAsyncKeyState Lib “user32” (ByVal vKey As Long) As Integer

    STbtn:

    Timer1.Start()

    STPbtn:
    Timer1.Stop()

    Timer1:
    Dim BMP As New Drawing.Bitmap(1, 1) Dim GFX As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(BMP) GFX.CopyFromScreen(New Drawing.Point(MousePosition.X, MousePosition.Y), _ New Drawing.Point(0, 0), BMP.Size) Dim Pixel As Drawing.Color = BMP.GetPixel(0, 0) CPpanel.BackColor = Pixel Redtxt.Text = Pixel.R Greentxt.Text = Pixel.G Bluetxt.Text = Pixel.B

    SSChk:
    If (GetAsyncKeyState(117)) Then Timer1.Start() End If If (GetAsyncKeyState(118)) Then Timer1.Stop() End If


    :::::::::::::: FULL SOURCE CODE (READY TO ADD) ::::::::::::::::

    Public Class Form1
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
    
    Private Sub STbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles STbtn.Click
    Timer1.Start()
    End Sub
    
    Private Sub STPbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles STPbtn.Click
    Timer1.Stop()
    End Sub
    
    Private Sub SSchk_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SSchk.Tick
    If (GetAsyncKeyState(117)) Then
    Timer1.Start()
    
    End If
    If (GetAsyncKeyState(118)) Then
    Timer1.Stop()
    
    End If
    End Sub
    
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Dim BMP As New Drawing.Bitmap(1, 1)
    Dim GFX As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(BMP)
    GFX.CopyFromScreen(New Drawing.Point(MousePosition.X, MousePosition.Y), _
    New Drawing.Point(0, 0), BMP.Size)
    Dim Pixel As Drawing.Color = BMP.GetPixel(0, 0)
    CPpanel.BackColor = Pixel
    Redtxt.Text = Pixel.R
    Greentxt.Text = Pixel.G
    Bluetxt.Text = Pixel.B
    End Sub
    End Class
    End Sub
    
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Dim BMP As New Drawing.Bitmap(1, 1)
    Dim GFX As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(BMP)
    GFX.CopyFromScreen(New Drawing.Point(MousePosition.X, MousePosition.Y), _
    New Drawing.Point(0, 0), BMP.Size)
    Dim Pixel As Drawing.Color = BMP.GetPixel(0, 0)
    CPpanel.BackColor = Pixel
    Redtxt.Text = Pixel.R
    Greentxt.Text = Pixel.G
    Bluetxt.Text = Pixel.B
    End Sub
    End Class

     

    #186875
    String
    Member

    In your “: FULL SOURCE CODE (READY TO ADD) :” section, You might want to add a comment mentioning what Timer1’s interval is.

    Good post, thanks for sharing.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.