[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

converting access default back color of -2147483633 to RGB value

Posted on 2006-07-14
6
Medium Priority
?
1,873 Views
Last Modified: 2012-05-05
Trying to get the RGB color for the deafult background color on access forms.  The value is -2147483633.  All the functions I found to not handle negative numbers.   I must be missing something.  This may not be terribly difficult but 500 points to the person that can get me the answer quickest.  thanks


'this function I found on EE does not handle negative values.   ???

Public Sub CompositeRGB( _
  ByVal lngRGB As Long, _
  ByRef intRed As Integer, _
  ByRef intGreen As Integer, _
  ByRef intBlue As Integer)
 
' Calculate discrete RGB colours from composite colour value.
'
' 1999-08-20. Cactus Data ApS, CPH
 
  If lngRGB < 0 Then
    ' Nothing to do.
    intRed = 0
    intGreen = 0
    intBlue = 0
  Else
    ' Dissolve composite RGB into discrete colours.
    intRed = lngRGB And vbRed '
    intGreen = (lngRGB And vbGreen) / &H100
    intBlue = (lngRGB And vbBlue) / &H10000
  End If
  Debug.Print intRed, intGreen, intBlue

End Sub
0
Comment
Question by:andyringle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 17110245
Taking an educated guess, if its positive, it divies it, what if u multiplied it?

If lngRGB < 0 Then
    ' Nothing to do.
    intRed = lngRGB And vbRed
    intGreen =  (lngRGB And vbGreen) * &H100
    intBlue = (lngRGB And vbBlue) * &H10000
  Else
    ' Dissolve composite RGB into discrete colours.
    intRed = lngRGB And vbRed '
    intGreen = (lngRGB And vbGreen) / &H100
    intBlue = (lngRGB And vbBlue) / &H10000
  End If



not guaranteed to work, but like I said, a guess
0
 

Author Comment

by:andyringle
ID: 17110349
Rickiroads

Thanks for the suggestion.  I gave it a go.   here is what I got:

Input:
lngRGB = -2147483633

Output:
intRed  = 15
intGreen  = 0
intBlue  = 0

This give me a color close to Black.  

I will keep trying other ways.....Any other suggestions......

Andy







0
 
LVL 65

Accepted Solution

by:
rockiroads earned 2000 total points
ID: 17110384
ok, what about this
paste this code in a module


Private Declare Sub CopyMemory Lib "kernel32" _
   Alias "RtlMoveMemory" _
  (ByRef Destination As Any, _
   ByRef Source As Any, _
   ByVal Bytes As Long)

Private Declare Function OleTranslateColor Lib "olepro32.dll" _
  (ByVal OLE_COLOR As Long, _
   ByVal HPALETTE As Long, _
   pccolorref As Long) As Long


Private Function GetRBGFromOLEColour2(ByVal dwOleColour As Long) As Byte()
   
  'pass a hex colour, return the rgb components
   Dim clrref As Long
   Dim b(1 To 4) As Byte
   
  'translate OLE color to valid color if passed
   OleTranslateColor dwOleColour, 0, clrref

  'copy the color into a byte array
  'the size of the long (4 bytes)
   CopyMemory b(1), clrref, 4
   
  'return the byte array. Note there
  'is no value in byte(4).
   GetRBGFromOLEColour2 = b()
 
End Function


'Now func uses long
'but this is how we can also use Hex or long
e.g.


Public Sub testit()
   Dim dwOleColor As Long
   Dim clrs() As Byte
   
   'Pass in hex or long
   dwOleColor = &H80000018
   clrs() = GetRBGFromOLEColour2(16777215)
   
   Debug.Print "R", clrs(1)
   Debug.Print "G", clrs(2)
   Debug.Print "B", clrs(3)

   Debug.Print RGB(255, 255, 255)

End Sub




0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

Author Comment

by:andyringle
ID: 17110508
YOU GOT IT!!

Input:
lngRGB = -2147483633

Output:
R              236
G              233
B              216


I did a test and it worked great!  Thanks for the help

FYI...I did some checking and the standard windows colors are as follows:


Color ID... Color Description
----------- -----------------
-2147483648 Scroll bar
-2147483647 Desktop
-2147483646 Active window title bar
-2147483645 Inactive window title bar
-2147483644 Menu bar
-2147483643 Window
-2147483642 Window frame
-2147483641 Menu Text
-2147483640 Window Text (*)
-2147483639 Title bar text
-2147483638 Active window border
-2147483637 Inactive window border
-2147483636 Application background
-2147483635 Highlight
-2147483634 Highlight Text
-2147483633 3-D face (**)
-2147483632 3-D shadow
-2147483631 Dimmed (disabled) text
-2147483630 Button Text
-2147483629 Inactive window title bar text
-2147483628 3-D highlight (***)
-2147483627 3-D dark shadow
-2147483626 3-D light
-2147483625 ToolTip Text
-2147483624 ToolTip background
-2147483621 Active window title bar color2


Will use that function to conver the colors above to RGB.

0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17110644
Nice!
0
 

Author Comment

by:andyringle
ID: 17110674
Rickiroads:

Thanks again for the help!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

650 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