Solved

Changing Colors At Runtime.

Posted on 2002-06-09
3
177 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 50

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 50

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

803 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