Changing Colors At Runtime

.net , vb6 India
  • 18 years ago

    Hi,


    I am having 100 odd forms in my application and there are average 25 controls like textbox,
    labels, Picture control etc. on each form.


    I want to implement color themes in my application. i.e. the user will choose the theme he would
    like to work from the Options Menu and based on his preference I want to change the backcolor
    and forecolor properties of each form when the form is loaded.


    My questions are:
    1. Will it slow down the form loading process if I change the color of each control on form load?
    2. Is there another better way of doing stuff like this?


    Thanks.

  • 18 years ago

    Dang man, what are you trying to create?!?!  100 forms with 25 controls in each? Thats like overkill for me!! ;D


    Answers:
    1) Shouldn't really be noticeable, but you have 100 forms.... so it might take awhile to load it all
    2) Are you doing it in .NET or VB6?


    If its in .NET you can probably try making an array of forms... like


    Code:

        dim forms(100) as system.windows.forms.form
        dim i as integer
        dim color as color
        color = color.aqua


        for i = 1 to 100
            forms(i).backcolor = color
        next i



    that should do it , but then you have to get all the controls on the form thru runtime... (big pain in the ass)


    just an idea


  • 18 years ago

    hmmmmm....


    thats an awful lot of forms, too many acctually. Try reducing it because everytime you hav another form it adds a few more kb's onto your total size... now multiply by hundred(dont forget to inclde all those controls) and you have a GodZilla! A) Waste of size B) iTs a resorce hogger.


    OKay off to your problem.


    1. Definetly! Even if your seeing the form at different times it's still going overkill.
    2. Not sure.


    Trust me... you wanna reduce the forms

  • 18 years ago

    I definitely agree with Websoftware, wayy too many forms!  But if you still want, I have found another solution that will work for .NET and VB6, but with .NET you'll have to declare the form.


    Now I am not verygood with VB6 but heres the theory behind it.  Ok create a sub procedure that would take an argument that is actually a color...In the sub procedure do this:


    form1.backcolor = newColor
    form2.backcolor = newColor
    form3.backcolor = newColor
    form4.backcolor = newColor


    etc...


    What are you trying to do that requires so many forms?  We can probably come up with a better way instead of having 100 different forms

  • 18 years ago

    I am trying to create a Share Market software...It involves different aspects of the market like accounting, price history etc....


    So the conclusion is that if I change the color of the form and its controls before loading the fomr...it will fractionally delay the form loading...Right??

  • 18 years ago

    Right - it'll detract slightly from load time but you won't notice on a decent spec machine.


    I agree with most people who have posted on this thread though... you probably have too many forms. Think of even the biggest MS Apps, or other companies. There's no way they have 100 forms and with all due respect, their programs are likely to be more powerful than yours.


    But if you're comfortable with it then go for it... If it aint broke, don't fix it.


    Regards,
    Louis Rose.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The difference between theory and practice is smaller in theory than in practice.”