Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.basic.visual.misc > #1585

Re: Color names in color picker used in font common dialog

From "Mike Williams" <Mike@WhiskyAndCoke.com>
Newsgroups microsoft.public.vb.general.discussion, comp.lang.basic.visual.misc
Subject Re: Color names in color picker used in font common dialog
Date 2012-10-08 22:42 +0100
Organization A noiseless patient Spider
Message-ID <k4vhbd$5eb$1@dont-email.me> (permalink)
References <vk1678de7er1issddh1c0ut44f9nr9t5u9@4ax.com> <k4v4pb$jle$1@dont-email.me> <hke678hoho2q4j8n9jlcvlcecf4eke454p@4ax.com>

Cross-posted to 2 groups.

Show all headers | View raw


"-mhd" <not_real@invalid.com> wrote in message 
news:hke678hoho2q4j8n9jlcvlcecf4eke454p@4ax.com...
>>> "Jeff Johnson" <i.get@enough.spam> wrote:
>>>
>>>Try http://www.blacksunsoftware.com/screenmagnifier.html
>>>It'll tell you the color value of the pixel under the cursor.
>
> I don't think any of those utilities (I have a few) give the long
> rgb value but rather the RGB separate values.

Well write your own then. It's fairly straightforward. As an example, paste 
the following code into a VB Form containing one Timer control.

Mike

Option Explicit
Private Declare Function SetWindowPos Lib "user32" _
  (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
  ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
  ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function GetDC Lib "user32" _
  (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" _
  (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function GetCursorPos Lib "user32" _
  (lpPoint As POINTAPI) As Long
Private Declare Function GetDesktopWindow _
  Lib "user32" () As Long
Private Declare Function GetPixel Lib "gdi32" _
  (ByVal hdc As Long, ByVal x As Long, _
  ByVal y As Long) As Long
Private Type POINTAPI
  x As Long
  y As Long
End Type
Private Const SWP_NOSIZE As Long = &H1&
Private Const SWP_NOMOVE As Long = &H2&
Private Const HWND_TOPMOST As Long = -1&
Private mypointer As POINTAPI
Private DesktopDC As Long

Private Sub Form_Load()
SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 360, 0, _
  SWP_NOMOVE
End Sub

Private Sub Timer1_Timer()
Dim retval As Long, s1 As String
DesktopDC = GetDC(0&)
' get mouse x, y coordinates
GetCursorPos mypointer ' cursor x,y position
retval = GetPixel(DesktopDC, mypointer.x, mypointer.y)
s1 = s1 & "     R " & Format(retval And &HFF)
s1 = s1 & " : G " & Format((retval \ &H100&) And &HFF)
s1 = s1 & " : B " & Format((retval \ &H10000) And &HFF)
s1 = s1 & " : " & "&H" & Right$("000000" & Hex$(retval), 6)
Caption = s1
ReleaseDC GetDesktopWindow, DesktopDC
End Sub

Back to comp.lang.basic.visual.misc | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Color names in color picker used in font common dialog -mhd <not_real@invalid.com> - 2012-10-08 13:12 -0400
  Re: Color names in color picker used in font common dialog "Jeff Johnson" <i.get@enough.spam> - 2012-10-08 14:07 -0400
    Re: Color names in color picker used in font common dialog -mhd <not_real@invalid.com> - 2012-10-08 16:47 -0400
      Re: Color names in color picker used in font common dialog "Mayayana" <mayayana@invalid.nospam> - 2012-10-08 17:20 -0400
        Re: Color names in color picker used in font common dialog -mhd <not_real@invalid.com> - 2012-10-08 19:29 -0400
        Re: Color names in color picker used in font common dialog -mhd <not_real@invalid.com> - 2012-10-08 20:14 -0400
          Re: Color names in color picker used in font common dialog Schmidt <sss@online.de> - 2012-10-09 06:21 +0200
            Re: Color names in color picker used in font common dialog "Norm Cook" <normcook@cableone.net> - 2012-10-09 07:08 -0500
              Re: Color names in color picker used in font common dialog Schmidt <sss@online.de> - 2012-10-09 16:05 +0200
                Re: Color names in color picker used in font common dialog "Mayayana" <mayayana@invalid.nospam> - 2012-10-09 10:28 -0400
            Re: Color names in color picker used in font common dialog "CoderX" <coder@x.com> - 2012-10-09 16:38 -0400
            Re: Color names in color picker used in font common dialog Ulrich Korndoerfer <ulrich_wants_nospam@prosource.de> - 2012-10-09 23:05 +0200
      Re: Color names in color picker used in font common dialog "Mike Williams" <Mike@WhiskyAndCoke.com> - 2012-10-08 22:42 +0100
        Re: Color names in color picker used in font common dialog "Mike Williams" <Mike@WhiskyAndCoke.com> - 2012-10-08 22:49 +0100
          Re: Color names in color picker used in font common dialog -mhd <not_real@invalid.com> - 2012-10-08 20:15 -0400
      Re: Color names in color picker used in font common dialog Deanna Earley <dee.earley@icode.co.uk> - 2012-10-09 09:30 +0100
      Re: Color names in color picker used in font common dialog "Jeff Johnson" <i.get@enough.spam> - 2012-10-09 13:52 -0400
  Re: Color names in color picker used in font common dialog "DaveO" <djo@dial.pipex.com> - 2012-10-09 11:57 +0100
    Re: Color names in color picker used in font common dialog "DaveO" <djo@dial.pipex.com> - 2012-10-09 15:21 +0100
      Re: Color names in color picker used in font common dialog -mhd <not_real@invalid.com> - 2012-10-09 13:10 -0400
    Re: Color names in color picker used in font common dialog -mhd <not_real@invalid.com> - 2012-10-09 12:58 -0400
      Re: Color names in color picker used in font common dialog -mhd <not_real@invalid.com> - 2012-10-09 15:14 -0400
        Re: Color names in color picker used in font common dialog "Mayayana" <mayayana@invalid.nospam> - 2012-10-09 17:33 -0400
          Re: Color names in color picker used in font common dialog -mhd <not_real@invalid.com> - 2012-10-09 17:49 -0400
  Re: Color names in color picker used in font common dialog Stan Weiss <srweiss@erols.com> - 2012-10-09 13:09 -0400

csiph-web