Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2006

Tip: Looking for answers? Try searching our database.

Application wide color and font settings?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve - 02 Mar 2006 20:02 GMT
I am finding that I'm adjusting the colors and font sizes on all my controls
to achieve the look that I want.  Without getting into the topic of whether
or not this is a good idea, is there a way to change the default colors for
all controls at the application level?  (IE: I drag a label control onto a
form and it's next is the shade of grey that I want?)

I know I can change the windows system colors and this will effect my app as
well, but I would like to just change the colors in my app.

I thought about adding entries in the ApplicationSettings then initializing
all my controls to that value, but that requires me to add code for each
control and creates a maintenance issue (deleting a control from the
designer will produce unknown types in my constructors, etc)

Maybe someone has some other tricks for me?  Is there something built in?

Thanks!
Stoitcho Goutsev (100) - 03 Mar 2006 14:23 GMT
Steve,

If you don't set the control's background color for example explicitly it
uses the color of its container. If the container's color is not set it uses
its container color and so on and so forth. The same goes for fonts. That
means if you set the form's color and font only all the control on the form
will have the same background color as the form and use the same font.

Is this what you are after?

Signature

Stoitcho Goutsev (100)

>I am finding that I'm adjusting the colors and font sizes on all my
>controls to achieve the look that I want.  Without getting into the topic
[quoted text clipped - 13 lines]
>
> Thanks!
Cerebrus - 03 Mar 2006 15:45 GMT
Hi Stoitcho,

I think that what he is really after is "How to change the settings for
all forms in an Application". (though I may be wrong, of course.)

Do you know of any way to do that ?

Regards,

Cerebrus.
Stoitcho Goutsev (100) - 03 Mar 2006 20:05 GMT
Cereberus,

Control class has static proeprties for default colors, fonts, etc.
Unfortunately they cannot be changed because they are readonly and simply
return the SystemColors values.

I don't know of any simple solution. In unmanaged application one can use
windows hooks for that. In  windows forms only the form's properties needs
to be altered, so I would do some fromfactory and use it whenever I need to
create a form. The factory will set the properties upon creation.

Signature

Stoitcho Goutsev (100)

> Hi Stoitcho,
>
[quoted text clipped - 6 lines]
>
> Cerebrus.
Cerebrus - 03 Mar 2006 22:44 GMT
Thanks Stoitcho,

I'll have to check out what a FormFactory is !!

Regards,

Cerebrus.
Stoitcho Goutsev (100) - 06 Mar 2006 14:12 GMT
FormFactory would be a class that I'd write.
it will have one static method CreateForm for example. Having this factory
instead creating forms using the *new* operator MyForm f = new MyForm(), I'd
call MyForm f = (MyForm)FormFactory.CreateForm(....);
In CreateForm I'm going to create the form and set all the default values
for the properties. The CreateForm method should except some parameter (such
a Type object) that specifies the type of the form that needs to be created.
It could be also a value from some predefined enumberation of form types.

Signature

Stoitcho Goutsev (100)

> Thanks Stoitcho,
>
[quoted text clipped - 3 lines]
>
> Cerebrus.
Cerebrus - 06 Mar 2006 16:12 GMT
My ! That sounds like a really cool idea. Would really save a lot of
time.

Thanks for the reply,

Regards,

Cerebrus.
Steve - 03 Mar 2006 16:17 GMT
Hi Stoitcho,

I was thinking too hard about this issue, I didn't see the obvious!  :)

So if all my UI is UserControls hosted in a single panel in a Form, I can
just set the form properties.  That will work well.  I was also going to use
ApplicationSettings to store the color and "LookAndFeel" values.

Thanks for cluing me in.
Have a great weekend,
Steve

> Steve,
>
[quoted text clipped - 24 lines]
>>
>> Thanks!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.