|
-
Jul 18th, 2003, 08:04 AM
#1
Thread Starter
Member
Reading Color values from registry won't work? Help! [solved]
Hello,
I created some entries in the registry where I want to save my colors.
It saves it in the registry as
Name: Background
Type: REG_DWORD
Data: ff400000
When I try to read it with
regKey = Registry.LocalMachine.OpenSubKey("Software\testprogram\colors", True)
msgbox(regKey.GetValue("background"))
I am getting a value of -12345902
I can't figure out how to get the "ff400000" value
then the other problem is how can I put it back as a background
color
Me.BackColor = "ff400000" won't work..
Can someone help me with these 2 little problems.
Thanks so much.
Perry
Last edited by mrdutchie; Jul 20th, 2003 at 11:30 AM.
-
Jul 18th, 2003, 08:27 AM
#2
OK,
Create a new project (just one form). Put a label, a combo box and two buttons on it.
Add the following code.
Button1 writes the selected colour to the registry. Button two retrieves the colour and sets the background of the label accordingly.
Hope this helps you on your way.
VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
With ComboBox1.Items
.Add(KnownColor.Red)
.Add(KnownColor.Yellow)
.Add(KnownColor.Blue)
End With
ComboBox1.SelectedItem = KnownColor.Red
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
SaveSetting("MyApp", "Colour", "Background", ComboBox1.SelectedItem.ToString)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Dim strColour As String
strColour = GetSetting("MyApp", "Colour", "Background")
Label1.BackColor = Color.FromName(strColour)
End Sub
This world is not my home. I'm just passing through.
-
Jul 18th, 2003, 12:36 PM
#3
Addicted Member
Save the Color.ToRBG property to the registry!
When reading it use the Color.FromRBG function.
-
Jul 20th, 2003, 11:30 AM
#4
Thread Starter
Member
[solved]
Thanks,
Got everything to work now.
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
|