|
-
May 14th, 2013, 11:57 AM
#1
Thread Starter
New Member
Allowing Control of Form Colours During Usage
Off Topic...No I will not change the "colours" in the title to the American spelling, stop trying to correct me Google.
Anyway. (sorry)
Note: This is being done in a Windows Forms Application using VB (wasn't entirely sure where to put this topic, staff please move if necessary. Thanks )
Right my question is really simple, you know how you can choose what colour you want windows to be and it changes everything to that scheme? I want to do that...kind of, for my app.
Scenario:
I have built an application and am revamping its UI to a more modern look (out with the default windows forms style in with my own). This new design is very much based on the latest microsoft designs (really basic with colourful buttons etc) which I love so much (I like basic and colourful)
So I have done the UI all nice, it looks good personally, but that is the issue. It's a personal preference. Some people who use my app may not like the same colours as me, or they may struggle with it etc etc.
Now I don't have a huge user base, the app is small and simple designed for some forum staff to use on a gaming servers' forum I'm a member of.
So I don't mind recolouring the main parts if its desired for each person (it will take me a while though obviously)
So what I want to be able to do is set a new form/settings menu. Where I can press a link to pick and then change the "colour scheme".
It currently is a dark grey background which white text and purple menu buttons. (very simple colouring method, its either grey white or purple)
But I am happy to program this settings page to contain a few pre-defined colour schemes which will change the app UI.
Example, instead of grey/purple the user could pick white/blue etc. (So not fully customization but partially)
I'm thinking it would look like this, but not sure and don't want to risk messing up the colours as they are. So some confirmation would be fantastic.
Code:
private sub linkClicked (event stuff) handles blueLabelClicked
_______.BackColour.White
End Sub
The big _____ is because I want to avoid setting each and every control (Like Form1, Button1, button2 etc etc.) but don't know if there is a global setting for "All buttons"
My question:
How would I go about programming the links in this menu to switch the "colour schemes"?
-
May 14th, 2013, 12:15 PM
#2
Re: Allowing Control of Form Colours During Usage
Every container (Form, Panel, GroupBox) has its own Controls collection so it is possible to set properties for many controls. For example,
vb.net Code:
For Each ctl In Controls.OfType(Of Button)() ' all buttons contained by Form
ctl.BackColor = Color.Aqua
Next
For Each ctl As Control In Panel1.Controls ' all controls contained by a panel
ctl.BackColor = Color.Aqua
Next
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
May 14th, 2013, 12:20 PM
#3
Re: Allowing Control of Form Colours During Usage
However, there is nothing like CSS in Windows Apps, so you would have to make all the changes. The code can help you getting to all the items, but you will have to visit each one using something like what Dunfiddlin showed.
One point to note is that color blindness is common, and variable. I had a high-contrast app for use in bright conditions, but was amused to hear my boss (red-green color blind) discussing it with a tech who worked for me (totally color blind). They were both wrong, but to varying degrees. It was entertaining.
My usual boring signature: Nothing
 
-
May 14th, 2013, 12:40 PM
#4
Thread Starter
New Member
Re: Allowing Control of Form Colours During Usage
 Originally Posted by dunfiddlin
Every container (Form, Panel, GroupBox) has its own Controls collection so it is possible to set properties for many controls. For example,
vb.net Code:
For Each ctl In Controls.OfType(Of Button)() ' all buttons contained by Form ctl.BackColor = Color.Aqua Next For Each ctl As Control In Panel1.Controls ' all controls contained by a panel ctl.BackColor = Color.Aqua Next
That looks wonderful.
To clarify, if I input this into the "Settings" form created for changing the colours, would it be needed only in the code for that form, or would it need to be referenced somehow to each form for it to change everything?
In other words, if it was written on the settings form's code would it only change the settings form or would it change all things in the app that it says to change?
EDIT: Found out its per form only. Would there be any way to globally adjust it?
 Originally Posted by Shaggy Hiker
However, there is nothing like CSS in Windows Apps, so you would have to make all the changes. The code can help you getting to all the items, but you will have to visit each one using something like what Dunfiddlin showed.
One point to note is that color blindness is common, and variable. I had a high-contrast app for use in bright conditions, but was amused to hear my boss (red-green color blind) discussing it with a tech who worked for me (totally color blind). They were both wrong, but to varying degrees. It was entertaining.
I always read "CSS" as counter strike source lol. Sorry, I'm a gamer.
I'll be honest I'm not entirely sure what you're referring to (I'm pretty new to programming, everything I know is self-taught).
I've never looked into CSS, obviously I don't need to as such with this app with it being so basic.
Are you trying to say that the code above would work but I would need to make sure I'm telling it every control that needs changing?
Could you elaborate please. 
As for the colour-blindness. I know, although I don't think any of my users are colour-blind, I would still like to be able to provide some level of adjustment so that they can find a colour scheme which works better for them, rather than pinning them to the colours I like and saying "get used to it".
I know it varies, but some level of adjustment will allow me to at least give some work around to those who may be colour-blind in different ways.
For the record, my dad is colour-blind (also red-green) I find it so much fun when he asks me what colour his shirt and tie are for work and then he argues because he can't see them the same as me. Bless him. "This is green isn't it?" "No dad its cream" "no it isn't" "oh ok you're right, after all you can see the colours can't you."
Last edited by LukeD1994; May 14th, 2013 at 12:48 PM.
-
May 14th, 2013, 12:54 PM
#5
Re: Allowing Control of Form Colours During Usage
If you have a separate settings form then you would need to reference everything in terms of the form it belongs to, yes. That's easily done by simply adding the form reference so Controls becomes Me.Controls for the settings form itself, Form1.Controls for the startup form etc.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
May 14th, 2013, 12:56 PM
#6
Thread Starter
New Member
Re: Allowing Control of Form Colours During Usage
 Originally Posted by dunfiddlin
If you have a separate settings form then you would need to reference everything in terms of the form it belongs to, yes. That's easily done by simply adding the form reference so Controls becomes Me.Controls for the settings form itself, Form1.Controls for the startup form etc.
That's excellent. I'll give it a try.
Thank you to both of you for providing assistance
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
|