Results 1 to 4 of 4

Thread: Reading Color values from registry won't work? Help! [solved]

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2003
    Posts
    58

    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.

  2. #2
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    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:
    1. Private Sub Form1_Load(ByVal sender As System.Object, _
    2.                            ByVal e As System.EventArgs) Handles MyBase.Load
    3.         With ComboBox1.Items
    4.             .Add(KnownColor.Red)
    5.             .Add(KnownColor.Yellow)
    6.             .Add(KnownColor.Blue)
    7.         End With
    8.  
    9.         ComboBox1.SelectedItem = KnownColor.Red
    10.     End Sub
    11.  
    12.     Private Sub Button1_Click(ByVal sender As System.Object, _
    13.                               ByVal e As System.EventArgs) Handles Button1.Click
    14.         SaveSetting("MyApp", "Colour", "Background", ComboBox1.SelectedItem.ToString)
    15.  
    16.     End Sub
    17.  
    18.     Private Sub Button2_Click(ByVal sender As System.Object, _
    19.                               ByVal e As System.EventArgs) Handles Button2.Click
    20.         Dim strColour As String
    21.         strColour = GetSetting("MyApp", "Colour", "Background")
    22.  
    23.         Label1.BackColor = Color.FromName(strColour)
    24.     End Sub
    This world is not my home. I'm just passing through.

  3. #3
    Addicted Member PeteD's Avatar
    Join Date
    Jun 2003
    Location
    Sydney
    Posts
    158
    Save the Color.ToRBG property to the registry!
    When reading it use the Color.FromRBG function.

  4. #4

    Thread Starter
    Member
    Join Date
    Jul 2003
    Posts
    58

    [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
  •  



Click Here to Expand Forum to Full Width