|
-
Jun 5th, 2005, 10:37 AM
#1
Thread Starter
Junior Member
-
Jun 5th, 2005, 11:29 AM
#2
Re: color code via color control?
Drop a ColorDialog control on to your form. Then this code will give you what you want except for the Hex number. It will use the .Color
property which contains the Long number format of the color. You just need to convert the long into hex and display in your label or ???
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
With ColorDialog1
.AllowFullOpen = True
.AnyColor = True
.FullOpen = True
.SolidColorOnly = False
If .ShowDialog = DialogResult.OK Then
Me.BackColor = .Color
Me.Label1.Text = Hex(.Color.ToArgb)
End If
End With
End Sub
Last edited by RobDog888; Jun 5th, 2005 at 11:38 AM.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 5th, 2005, 11:50 AM
#3
Re: color code via color control?
Forgot to mention that you may want to prepopulate the color dialog first so the custom colors pointer will be updated to the location of the color.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 5th, 2005, 12:50 PM
#4
Thread Starter
Junior Member
Re: color code via color control?
Great !! i have two questions though :
- the "SolidColorOnly" doesn't seem necessary (it works without it) , why did you put it there?
- When using your method , i get a Hex number of 8 digits whereas color codes go as long as 6 digits (Photoshop doesn't allow a hex code more than 6 digits). Any ideas on how to solve this problem?
-
Jun 5th, 2005, 12:56 PM
#5
Re: color code via color control?
The solidcoloronly = false will give the user the ability to choose any color. If you want web colors then it could be set to true. I think
that would be part of it but then sice web safe colors are not always just solid so you may need to determine the safe colors and if a non-safe one
is choosen then you can set it to the nearest safe color.
I think a little research on the 8 to 6 digits will be requred since I cant really answer it 100%. I think you need to get a hex color from PS and set
that as the start color in vb. Then you can see how it translates back to hex and see what the difference is. It may be that we are not using
the correct method for what you need?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 8th, 2005, 07:50 PM
#6
Thread Starter
Junior Member
Re: color code via color control?
I don't clearly understand what you mean by :
I think you need to get a hex color from PS and set
that as the start color in vb. Then you can see how it translates back to hex and see what the difference is.
I'm talking about color codes like this one. The link explains it all.
There's probably a way to convert the aRGB values into Hex. For example , my program produces "-16777216" when i chose black ; where in hex it should be "000000"
any ideas?
-
Jun 8th, 2005, 08:13 PM
#7
Re: color code via color control?
8 digits of hex is 4 bytes. In colors, that translates to ARGB. RGB are Red Green Blue, while A is an alpha value that I don't fully understand. I believe this has to do with alpha blending which allows varying levels of transparency, but I suck as an artist, so I don't pretend to try to use alpha blending. The game gurus can certainly explain that in greater detail.
I believe that the A from ARGB is the first two bytes, so you should be able to strip those off to get the RGB value that you want. You should be able to test that pretty easily, because a bright red would be 0xyyFF0000, or something close to that, while a bright green would be 0xyy00FF00, and a blue would be 0xyy0000FF. The yy in that case would be the alpha value, which you can ignore for 6 byte needs.
Since the color object has a FromARGB() function, it seems like you ought to also be able to confirm this by passing the value into that function, then checking the R, G, and B properties.
My usual boring signature: Nothing
 
-
Jun 9th, 2005, 08:10 AM
#8
Thread Starter
Junior Member
Re: color code via color control?
Shaggy Hiker , you're a genuis !!!
I converted the aRGB value to Hex , ignored the first two digits and it shows colors properly, thanks alot guys!!
-
Jun 9th, 2005, 10:42 AM
#9
Re: color code via color control? [Resolved]
Too late. I was thinking of this last night while trying to sleep and I realized that it was the alpha channel that was creating
the extra 2 digits.
Glad to see that we have great members like Shaggy that are on top of things while we are off line.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
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
|