|
-
Sep 15th, 2000, 01:30 PM
#1
Thread Starter
Junior Member
I can't figure it out. Please help me. I would like the user to be able to change the backcolor of all forms and controls (i.e., command buttons, labels, etc.) by selecting a color from the Common Dialog control (ShowColor). frmMain has a menu option to change the forms' backcolor and forecolor. How do implement this in code? I know how to do it on the same form, but how do I have it affect all forms and controls within the application????
-
Sep 15th, 2000, 01:36 PM
#2
Fanatic Member
Could be wrong
If you want to do this at run time...
(I could be wrong)
But I'd write a function that takes a form, and a color
as argument and
load the form (at start of app) (Don't Have to show it)
go thru all the controls on each of the forms and change the backcolor to the desired color
One note though:
For command buttons... You have to set the style to 'Graphical' before doing that
-
Sep 15th, 2000, 01:37 PM
#3
Lively Member
this might work
Code:
comondialog1.showcolor
Dim MyControl As Control
For Each MyControl In form1.Controls
MyControl.backcolor = commondialog1.color
Next
hope that helps...
-
Sep 15th, 2000, 03:16 PM
#4
You would need to loop through all Forms.
Code:
Dim frm As Form
Dim ctl As Control
For Each frm In Forms
For Each ctl In frm.Controls
If TypeOf ctl Is CommandButton Then ctl.BackColor = vbBlue
Next ctl
Next frm
-
Sep 15th, 2000, 03:49 PM
#5
Addicted Member
But this method doesn't work for all controls (I know it doesn't work for CommandButtons).
I've found some code about changing commandbutton's back color at www.vbaccelerator.com (I don't know exact URL) and I think it can be modified to change back colors of other controls, too.
Zvonko Bostjancic
Ilirska Bistrica, Slovenia
[email protected]
Using VS6 Professional with SP3
Programming mostly in VB and I've started to learn VC++ & MFC
-
Sep 15th, 2000, 03:56 PM
#6
You can change the background color of a CommandButton but it won't show unless you set it's Style property to 1 - Graphical.
-
Sep 19th, 2000, 03:15 PM
#7
Thread Starter
Junior Member
Success at last!!
Thanks to everyone who responded. You were all very helpful.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|