Solved

Changing Colors At Runtime.

Posted on 2002-06-09
3
179 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 51

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 51

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

680 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