CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: SETTINGS

  1. #1
    Join Date
    Sep 2000
    Posts
    58

    SETTINGS

    Does anyone know how to easily save the settings for each object on a form (either into registry or ini) so that if for eg. someone changes the background color it is stored.

    As I need to save about 10 settings per object and I have up to 20 objects on a form and I may have 30 forms, saving each setting individually is not practical.

    What l need is a module that allows me to simply send through the formname and have the module loop through all the settings on each form.




  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: SETTINGS

    Use WriteProfileString and GetProfileString to read and write values to the registry.

    Yes, you can write a function that takes a form as an argument as follows


    public Sub SaveParams(aForm as Form)
    dim aControl as Controls
    for each aControl in aForm.Controls
    'You can access the properties of the control using aControl.PropertyName
    'And Concatenate them into a string
    next
    'Finally save the string using WriteProfileString here
    End Sub





  3. #3
    Join Date
    Sep 2000
    Posts
    58

    Re: SETTINGS

    This is the problem, each control has different properties (or settings), so specifing each property for each control on every form would require 100's of lines of code. I need to be able to loop through the properties, not just the controls.

    Thanks for your help.


  4. #4
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: SETTINGS

    Just use a superset of all properties, I mean, save all properties that you can think of, without concerning whether a control has it or not. It is sure that you'll get an error, but it doesn't matter, use an On Error Resume Next. It is a crude method however.


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

Featured