Visual Basic .Net


VB Color Picker

VB Projects, VB Source Codes

  • visual basic page on facebook
  • Auth : (Evry1falls)
  • Occ. : Software Developer
  • Occ. : Freelancer

visual basic programming project - search
vb net vb6 vb office Crystal Reports for VB Sql Server for VB Source Code Software Development
Visual Basic 6 Projects VB.Net Projects

visual-basic-6-count-down-timer-ocxvb6 project Color Picker and Cursor location

Key Subjects /

  • How to retrieve the RGB Color code and Cursor X,Y co-ordinates.
  • What is a Color Picker ?
  • How colors work in VB ?
  • Project design in Visual Basic 6.0
  • What to expect from this vb project ?
  • The usage of vb 6 built-in functions
  • VB 6 source code project download
  • VB 6 code preview

vb color pickerRetrieve RGB color and Cursor location

In the field of software development and software editing field, every developer needs tools to finish his job, this tool could be [Text editor],[Image editor],[Color Picker] and even more tools to help him/her creating the desired application without bugs.

  • Tools are essentials for any developer

Those tools could be made in any programming language, sometimes it matters and sometimes it doesn't matter, all what needed is an effective tool to help. The tool could be migrated in the programming IDE or the programming code editor, or it could be an external tool.

  • It doesn't matter what the tool is, what matter is what the tool does.

When it comes to software development, I could use a tool like Color Picker to get the RGB code of any color I desire from any photo I desire, Or I can design a Color Picker small app to use it inside my big application or software.

vb color pickerWhat is vb Color Picker ?!!

A Color Picker, ColorPicker or Color Pacifier is a tool that picks a color in some format from any coloful interface and return the color format picked. The Adobe PhotoShop Pacifier is a good example vb6 colorpicker source code example ico and the Microsoft Visual Basic Color Picker Box is too. RGB stands for (Red, Green, Blue) and this is somehow the color format that our ColorPicker will return when it hovers a colorful interface (Anything on a windows desktop like Icons, Pictures, folders or even in the software application itself).

VB6 Color Picker Source Code emaple
Photo - VB Color Picker Example

vb color pickerHow colors work in VB ?!!

Microsoft Visual Basic 6.0 represented colors as values of a type Long. Visual Basic 6.0 color constants are :

Color Constant Equivalents
System Color Constant Equivalents

Using the above table, you can set the color of any colorable Visual Basic item interface (BackColor, ForeColor), I.e :

The effect on the TextBox (Text1) control can be seen on the both IDE and run-time environments (When designing and executing of the project).

The color constants are also equivalents to the Hexadecimal values displayed in the I.e (BackColor property of a TextBox) written :

Color Name
VB Constant

What is the Hexadecimal code for a color in Visual Basic 6.0 ?

The color code is devided into 2 sections :

  • (&H00) which represents (Hexadecimal)
  • (00 00 00) which is the RGB 'Red Green Blue' intensity values, but written backwords 'B G R', from the right to the left, the first (00) is the intensity of the Red color where (00) is the lowest and FF is the highest, the same applies to the Green and Blue.

vb color picker VB project design and notes .

We will create a very simple project in Visual Basic 6.0 to Pick any color from the Windows desktop items not limited to the the Visual Basic 6.0 application view and to get the Cursor co-ordinates X,Y from any place on the Windows desktop, not limited to the VB application view.

VB 6.0 Color Picker Project

  • You will find the Source Code (Visual Basic 6.0 Color picker.rar) for downloading directly from link in the end of the lesson.

We create a new Windows application project and place some labels (Label1, Label2 and Label3), a Timer and a PictureBox control.

vb color picker What to expect from this vb project ?!

Each time you move the mouse cursor on any place above any item on the Windows, the vb application will display the Cursor location (X,Y) and the surface color in RGB format.

I used some built-in functions and I developed some user-defined functions, the built-in finctions I used are :

  • GetCursorPos , GetPixel, CreateDC, DeleteDC

The user-defined functions I created were :

  • LongToRGB, GetPixelColor

By default, the Visual Basic 6.0 is not able to retrieve the RGB format of a color, because the color as we mentioned before is a value of a type Long, so it will be retrieved as a Long value, it will be converted to RGB (00 , 00 , 00)=(Red, Green, Blue), Where Red is a value from 0 to 255 and also the Green and the Blue, the maximum intensity is FF FF FF which represents the White Color.

vb color picker Built-in Functions in VB usage .

Function GetCursorPos.

This function will help on retrieving the position of the cursor wherever it moves inside and outside the Visual Basic 6.0 application. PosXY variable will hold the (X,Y) coordinates where the mouse is moving, and that will be included in a Timer Sub where Timer_Interval is (1 ms). Here is a separate Visual Basic 6.0 example on how to get the Cursor Positions.

Function GetPixel.

This function will return the color of any Pixel in the Windows OS. Parameters :
hdc As Long : Is the Long value of a Handel to a context device 'Long unique number to identify something programatically'

  • X As Long : Is the Long value of a co-odinate X 'Horizontal'
  • Y As Long : Is the Long value of a co-odinate Y 'Vertical'

Here is a project example on how to get a Pixel Color from winth in a PictureBox control in a Visual Basic 6.0 application

vb color picker VB 6 Color Picker Source Code Preview

Tags : software development, vb6 color picker, source code
Free Web Hosting