|
-
Apr 19th, 2005, 01:34 AM
#1
Thread Starter
Member
Convert form.backcolor value to long?
Hello. I am trying to use the CreateSolidBrush API to give my form's menu a particular color (in my case I just want to set the menu's color to the form's background color - right now the menu is white).
CreateSolidBrush expects a long value for the color. However, the form's .backcolor value in the properties window is some weird system color value, in this case "&H8000000F&". How do I convert this value to the long value I need for the CreateSolidBrush API? Is there another API call I need to use that retrieves the form's background color as a long value?
BTW I'm using VB6.
Many thanks in advance...
-
Apr 19th, 2005, 02:20 AM
#2
Re: Convert form.backcolor value to long?
Hmmmmnnnn.... will the CLNG help?
-
Apr 19th, 2005, 02:26 AM
#3
Thread Starter
Member
Re: Convert form.backcolor value to long?
I tried that but of course it didn't work Why does a seemingly easy thing have to be so difficult?
-
Apr 19th, 2005, 03:40 AM
#4
Re: Convert form.backcolor value to long?
Add this code to your form.
The "weird" value is the hexadecimal representation of the back colour. This code shows the hex and decimal representations.
VB Code:
Option Explicit
Private Sub Form_Load()
MsgBox Hex(Me.BackColor) & " as a decimal is " & Me.BackColor, , "Form Back Colour"
End Sub
This world is not my home. I'm just passing through.
-
Apr 19th, 2005, 10:17 AM
#5
Re: Convert form.backcolor value to long?
All colours that a user can change via the Windows Display Properties are System Colours. To get the actual colour, you need to find the color index and then pass that to the GetSysColor API.
Check this thread for some code
-
Apr 19th, 2005, 10:29 AM
#6
Thread Starter
Member
Re: Convert form.backcolor value to long?
Thanks brucevde. Oe last thing. That article mentions:
"The last byte of a system colour constant contains the index you need. So for &H8000000F&, it would be Hex F = 15. For Button Text (ForeColor property, typically &H80000012&) it would be Hex 12 (18)."
How do you extract "the last byte" of the system color? I realize I could just type Hex(F) or Hex(12) - but of course I'd like to dynamically extract that piece of info. Thanks again...
-
Apr 19th, 2005, 10:37 AM
#7
Re: Convert form.backcolor value to long?
VB Code:
Debug.Print Me.BackColor And &HFF
This world is not my home. I'm just passing through.
-
Apr 19th, 2005, 10:41 AM
#8
Addicted Member
Re: Convert form.backcolor value to long?
How do you extract "the last byte" of the system color? I realize I could just type Hex(F) or Hex(12) - but of course I'd like to dynamically extract that piece of info. Thanks again...
Like Tris posted, but I'd like to note that Hex() is for converting decimal to Hex, not the other way around.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|