Solved

Changing Colors At Runtime.

Posted on 2002-06-09
3
176 Views
Last Modified: 2010-05-02
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.
0
Comment
Question by:Sethi
  • 2
3 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 7066341
Of course, it will slow down your application because more resources are used.

What you may need is the global variables, then save in your memory to keep track what colos/ themes should be used in your application.

Example:

Define a module:

Public mycolor As Long

Sub Main()
   mycolor = RGB(255,0,0) 'Set the default color
   Load frmMain
End Sub

In your form_load event:

Private Sub Form_Load()
    Me.BackColor = mycolor
    'or you can do whatever refer to the global variables' value
End Sub

Hope this is clear and make helps
0
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 50 total points
ID: 7066343
Additional:

To set all color of opened forms:
Dim myForm As Form

For each myForm in Forms
   myForm.BackColor = mycolor
Next

Cheers
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7068414
What I'd recommend is allowing the user to control you application's colors through the Windows theme.

If you keep all of your controls set to the Windows colors (rather than palette colors) then your app will change any time the Windows colors are changed.

For example, command buttons typically have the Backcolor set to &H8000000F&.  On most systems this appears gray/silver, but on system that have alternate Windows themes, this button will appear that same as buttons in other applications.

If you change the Backcolor to &Hc0c0c0, it will appear gray/silver regardless of Windows.  Usually this is considered "unprofessional" so it's nice that you're allowing your users to change colors, but wouldn't they want your app to match all the other apps on their system?  If so don't re-invent the wheel; just use system colors on all your controls.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now