Solved

color and &HF0000000

Posted on 1998-09-21
9
557 Views
Last Modified: 2008-02-01
I thought we need 6 digits to represent a color....but i found it is 8 digits, like &HF0000000.
Can you tell me how it works, which digit for what color?
0
Comment
Question by:learn
  • 4
  • 4
9 Comments
 
LVL 12

Accepted Solution

by:
mark2150 earned 40 total points
ID: 1435870
You get 8 digits because color is a LONG value. Only the bottom six are required and the leading two zero's are often omitted.

    pel = Me.Point(X, Y)
    B = (pel And &HFF0000) / 65536
    g = (pel And &HFF00) / 256 Mod 256
    r = pel And &HFF

0
 
LVL 1

Expert Comment

by:bharris1
ID: 1435871
I think THIS is the information that you requested.

It looks like we have &H00 at the beginning and & at the end with the middle 6 digits representing the colors:
0000xx - Red
00xx00 - Green
xx0000 - Blue

So we have:
&H000000FF&  - Red
&H0000FF00&  - Green
&H00FF0000&  - Blue
0
 

Author Comment

by:learn
ID: 1435872
Hi
Looks very interesting:
       pel = Me.Point(X, Y)
       B = (pel And &HFF0000) / 65536
       g = (pel And &HFF00) / 256 Mod 256
       r = pel And &HFF
is pel a color? why we can do 'pel and &HFF0000?
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1435873
Wanted to get each color on the 0-255 range. Not much use in having the B range from 65536 to 16711680 in steps of 65536. Much easier to understand when all are 0-255 plus now you can do:

Me.PSet (x, y), RGB(r, g, b)

and have it work.

0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:learn
ID: 1435874
Hi Experts:

I have just found a color from VB:
&H8000000F&
If only lower six digits are used, why they put "80" at the first two positoins?
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1435875
MSB is *sign* bit ... Where did you find this tidbit? I've never seen a color value like this.

Don't know how the color function works on an internal level. It may simply ignore the MS byte or it could use it as a signal to change color modes. This could indicate that the color requested is #15 in the 16 color EGA palette.
0
 

Author Comment

by:learn
ID: 1435876
In fact, I am using this color (&H8000000F& ) in my program and the color is the light gray, like the default back color of the form.

I want to use some very light colors but they must be solid...I have tried to use GBR() but not easy to found such color and that is why I copied the above color from VB.

Do you know how to make sure the color is solid from GBR() or from &H....&?
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1435877
How about a nice control to allow you to mix your own colors? You can diddle the RGB values until you have the color you want and it will show you what the RGB values are:

VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "COMCTL32.OCX"
Begin VB.Form Color
   Caption         =   "Color Test"
   ClientHeight    =   4665
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7530
   Icon            =   "colors.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   4665
   ScaleWidth      =   7530
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command1
      Cancel          =   -1  'True
      Caption         =   "Exit"
      Height          =   615
      Left            =   840
      TabIndex        =   14
      ToolTipText     =   "Click here to exit the program"
      Top             =   3840
      Width           =   5775
   End
   Begin VB.TextBox Text2
      Height          =   375
      Index           =   2
      Left            =   6720
      TabIndex        =   13
      Text            =   "Text2"
      ToolTipText     =   "Blue Setting"
      Top             =   3000
      Width           =   615
   End
   Begin VB.TextBox Text2
      Height          =   375
      Index           =   1
      Left            =   6720
      TabIndex        =   12
      Text            =   "Text2"
      ToolTipText     =   "Green Setting"
      Top             =   2520
      Width           =   615
   End
   Begin VB.TextBox Text2
      Height          =   375
      Index           =   0
      Left            =   6720
      TabIndex        =   11
      Text            =   "Text2"
      ToolTipText     =   "RED Setting"
      Top             =   2040
      Width           =   615
   End
   Begin VB.TextBox Text1
      Alignment       =   2  'Center
      Height          =   375
      Left            =   5640
      TabIndex        =   10
      Text            =   "Text1"
      ToolTipText     =   "Current Grey scale setting"
      Top             =   1320
      Width           =   975
   End
   Begin VB.PictureBox Picture2
      Height          =   1815
      Left            =   5640
      ScaleHeight     =   1755
      ScaleWidth      =   915
      TabIndex        =   3
      Top             =   1800
      Width           =   975
   End
   Begin VB.PictureBox Picture1
      Height          =   975
      Left            =   5640
      ScaleHeight     =   915
      ScaleWidth      =   915
      TabIndex        =   1
      Top             =   240
      Width           =   975
   End
   Begin ComctlLib.Slider Slider1
      Height          =   495
      Left            =   720
      TabIndex        =   0
      ToolTipText     =   "Adjust the grey scale level"
      Top             =   480
      Width           =   4575
      _ExtentX        =   8070
      _ExtentY        =   873
      _Version        =   327682
      Max             =   255
      TickFrequency   =   5
   End
   Begin ComctlLib.Slider Slider2
      Height          =   495
      Index           =   0
      Left            =   720
      TabIndex        =   2
      ToolTipText     =   "Adjust the amount of RED in the color mix"
      Top             =   1920
      Width           =   4575
      _ExtentX        =   8070
      _ExtentY        =   873
      _Version        =   327682
      Max             =   255
      TickFrequency   =   5
   End
   Begin ComctlLib.Slider Slider2
      Height          =   495
      Index           =   1
      Left            =   720
      TabIndex        =   8
      ToolTipText     =   "Adjust the amount of GREEN in the color mix"
      Top             =   2520
      Width           =   4575
      _ExtentX        =   8070
      _ExtentY        =   873
      _Version        =   327682
      Max             =   255
      TickFrequency   =   5
   End
   Begin ComctlLib.Slider Slider2
      Height          =   495
      Index           =   2
      Left            =   720
      TabIndex        =   9
      ToolTipText     =   "Adjust the amount of BLUE in the color mix"
      Top             =   3120
      Width           =   4575
      _ExtentX        =   8070
      _ExtentY        =   873
      _Version        =   327682
      Max             =   255
      TickFrequency   =   5
   End
   Begin VB.Label Label4
      Alignment       =   1  'Right Justify
      Caption         =   "Blue"
      Height          =   375
      Left            =   120
      TabIndex        =   7
      Top             =   3240
      Width           =   495
   End
   Begin VB.Label Label3
      Alignment       =   1  'Right Justify
      Caption         =   "Green"
      Height          =   375
      Left            =   120
      TabIndex        =   6
      Top             =   2640
      Width           =   495
   End
   Begin VB.Label Label2
      Alignment       =   1  'Right Justify
      Caption         =   "Red"
      Height          =   375
      Left            =   120
      TabIndex        =   5
      Top             =   2040
      Width           =   495
   End
   Begin VB.Label Label1
      Alignment       =   2  'Center
      Caption         =   "Grey Scale"
      Height          =   255
      Left            =   840
      TabIndex        =   4
      Top             =   120
      Width           =   4575
   End
End
Attribute VB_Name = "Color"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Command1_Click()
Call die
End Sub

Private Sub Form_Load()
Text2(0).BackColor = vbRed
Text2(0).ForeColor = vbWhite
Text2(0).Text = "0"
Text2(1).BackColor = vbGreen
Text2(1).ForeColor = vbWhite
Text2(1).Text = "0"
Text2(2).BackColor = vbBlue
Text2(2).ForeColor = vbWhite
Text2(2).Text = "0"
Call set_grey
Call set_color
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Call die
End Sub

Private Sub Slider1_Change()
Call set_grey
End Sub

Private Sub Slider1_Scroll()
Call set_grey
End Sub

Private Sub Slider2_Change(Index As Integer)
Call set_color
End Sub

Public Sub set_grey()
grey = Slider1.Value
Picture1.BackColor = RGB(grey, grey, grey)
Picture1.Cls
Picture1.Refresh
Text1.Text = grey
End Sub
Public Sub set_color()
red = Slider2(0).Value
green = Slider2(1).Value
blue = Slider2(2).Value
Picture2.BackColor = RGB(red, green, blue)
Picture2.Cls
Picture2.Refresh
Text2(0).Text = red
Text2(1).Text = green
Text2(2).Text = blue
End Sub

Private Sub Slider2_Scroll(Index As Integer)
Call set_color
End Sub
Public Sub die()
Dim frm As Form
    For Each frm In Forms
    Unload frm
    Next frm
End
End Sub

If this works - gimme da points!

M

0
 

Author Comment

by:learn
ID: 1435878
Hi mark2150:

I believe the code may help me.

However, I don't know how to make that work. I need to compile that or not?

your points will ve increased.

Cheers.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Controlling which port to download from 4 59
Help in WHSCRIPT 9 41
Determine Range to Select 5 33
VBA filters 2 37
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now