473,506 Members | 17,000 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

challenge?

this one is really a challenge to me.

the application i developed in VB.NET 2003 runs on marine boat, the
application has many screens and controls. On a marine boat at night, only
dark cyan (or similar) color must be used on display (much like the radar
display) otherwise the captain will be blinded by the bright colors.

When at night, the user clicks on a button to turn the application into
night mode. I do not want to go through all the objects (over 1000) to
change each color, I am thinking that maybe I can change the palette of
Windows or VB, the computer they are using is designated to run my
application only, so it will not affect other application.

Is there a way i can change for example the definition of
SystemColors.Control.Yellow to SystemColors.Control.DarkCyan at night mode
and return to normal on day mode?
Thanks in advance.
Nov 21 '05 #1
11 1348

anthony wrote:
this one is really a challenge to me.

the application i developed in VB.NET 2003 runs on marine boat, the
application has many screens and controls. On a marine boat at night, only dark cyan (or similar) color must be used on display (much like the radar display) otherwise the captain will be blinded by the bright colors.

When at night, the user clicks on a button to turn the application into night mode. I do not want to go through all the objects (over 1000) to change each color, I am thinking that maybe I can change the palette of Windows or VB, the computer they are using is designated to run my
application only, so it will not affect other application.

Is there a way i can change for example the definition of
SystemColors.Control.Yellow to SystemColors.Control.DarkCyan at night mode and return to normal on day mode?


Given that your app has sole use of the PC, sounds like the easiest way
would be to make sure all your controls use SystemColors, then change
the *global* Windows colour scheme (you know, where you set what colour
title bars and stuff are). I just did a quick test and a VB.NET 2002
app running on Win2k changes colours *automatically* when the Windows
colour scheme changes, so you should be alright.

Now the question becomes how to change that Windows setting? I suspect
it will involve P/Invoke'ing the API, but I don't expect it to be
particularly difficult. You can find this yourself, or you want more?

--
Larry Lard
Replies to group please

Nov 21 '05 #2

Larry Lard wrote:
anthony wrote:
this one is really a challenge to me.

the application i developed in VB.NET 2003 runs on marine boat, the
application has many screens and controls. On a marine boat at night, only
dark cyan (or similar) color must be used on display (much like the

radar
display) otherwise the captain will be blinded by the bright colors.
When at night, the user clicks on a button to turn the application

into
night mode. I do not want to go through all the objects (over

1000) to
change each color, I am thinking that maybe I can change the
palette of
Windows or VB, the computer they are using is designated to run my
application only, so it will not affect other application.

Is there a way i can change for example the definition of
SystemColors.Control.Yellow to SystemColors.Control.DarkCyan at
night mode
and return to normal on day mode?
Given that your app has sole use of the PC, sounds like the easiest

way would be to make sure all your controls use SystemColors, then change
the *global* Windows colour scheme (you know, where you set what colour title bars and stuff are). I just did a quick test and a VB.NET 2002
app running on Win2k changes colours *automatically* when the Windows
colour scheme changes, so you should be alright.

Now the question becomes how to change that Windows setting? I suspect it will involve P/Invoke'ing the API, but I don't expect it to be
particularly difficult. You can find this yourself, or you want more?


[replying to self]
(it's SetSysColor but...)
Actually, why re-invent the wheel? Just make sure your app uses only
SystemColor's for its colours, then the user can just use Control Panel
| Display to switch to a night-time scheme at night, and (as I have
established) your app will switch automatically.

--
Larry Lard
Replies to group please

Nov 21 '05 #3
"anthony" <an*******@controlengineer.com> wrote in
news:u$*************@TK2MSFTNGP15.phx.gbl:
this one is really a challenge to me.

the application i developed in VB.NET 2003 runs on marine boat, the
application has many screens and controls. On a marine boat at night,
only dark cyan (or similar) color must be used on display (much like
the radar display) otherwise the captain will be blinded by the bright
colors.

When at night, the user clicks on a button to turn the application
into night mode. I do not want to go through all the objects (over
1000) to change each color, I am thinking that maybe I can change the
palette of Windows or VB, the computer they are using is designated to
run my application only, so it will not affect other application.

Is there a way i can change for example the definition of
SystemColors.Control.Yellow to SystemColors.Control.DarkCyan at night
mode and return to normal on day mode?
Thanks in advance.


See getsyscolors and setsyscolors in the library (Platform SDK), not sure
how to use it. I'll have a go...
Nov 21 '05 #4
Thanks Larry,

Do you know which API to invoke? GDI+ or DirectX API or sth else...?
"Larry Lard" <la*******@hotmail.com> wrote in message
news:11*********************@c13g2000cwb.googlegro ups.com...

anthony wrote:
this one is really a challenge to me.

the application i developed in VB.NET 2003 runs on marine boat, the
application has many screens and controls. On a marine boat at

night, only
dark cyan (or similar) color must be used on display (much like the

radar
display) otherwise the captain will be blinded by the bright colors.

When at night, the user clicks on a button to turn the application

into
night mode. I do not want to go through all the objects (over 1000)

to
change each color, I am thinking that maybe I can change the palette

of
Windows or VB, the computer they are using is designated to run my
application only, so it will not affect other application.

Is there a way i can change for example the definition of
SystemColors.Control.Yellow to SystemColors.Control.DarkCyan at night

mode
and return to normal on day mode?


Given that your app has sole use of the PC, sounds like the easiest way
would be to make sure all your controls use SystemColors, then change
the *global* Windows colour scheme (you know, where you set what colour
title bars and stuff are). I just did a quick test and a VB.NET 2002
app running on Win2k changes colours *automatically* when the Windows
colour scheme changes, so you should be alright.

Now the question becomes how to change that Windows setting? I suspect
it will involve P/Invoke'ing the API, but I don't expect it to be
particularly difficult. You can find this yourself, or you want more?

--
Larry Lard
Replies to group please

Nov 21 '05 #5
I actually have to place a button or menu item on my application to do so, I
would have a hard time to explain what a Windows Control Panel to the boat
user/captain, so a one-click way is essental, I will look at the SetSysColor
you suggest.

Thanks!

"Larry Lard" <la*******@hotmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...

Larry Lard wrote:
anthony wrote:
this one is really a challenge to me.

the application i developed in VB.NET 2003 runs on marine boat, the
application has many screens and controls. On a marine boat at

night, only
dark cyan (or similar) color must be used on display (much like the

radar
display) otherwise the captain will be blinded by the bright colors.
When at night, the user clicks on a button to turn the application

into
night mode. I do not want to go through all the objects (over

1000)
to
change each color, I am thinking that maybe I can change the

palette
of
Windows or VB, the computer they are using is designated to run my
application only, so it will not affect other application.

Is there a way i can change for example the definition of
SystemColors.Control.Yellow to SystemColors.Control.DarkCyan at

night
mode
and return to normal on day mode?


Given that your app has sole use of the PC, sounds like the easiest

way
would be to make sure all your controls use SystemColors, then change
the *global* Windows colour scheme (you know, where you set what

colour
title bars and stuff are). I just did a quick test and a VB.NET 2002
app running on Win2k changes colours *automatically* when the Windows
colour scheme changes, so you should be alright.

Now the question becomes how to change that Windows setting? I

suspect
it will involve P/Invoke'ing the API, but I don't expect it to be
particularly difficult. You can find this yourself, or you want more?


[replying to self]
(it's SetSysColor but...)
Actually, why re-invent the wheel? Just make sure your app uses only
SystemColor's for its colours, then the user can just use Control Panel
| Display to switch to a night-time scheme at night, and (as I have
established) your app will switch automatically.

--
Larry Lard
Replies to group please

Nov 21 '05 #6
Bob
Just an idea, why not cut the wire to the monitor and install a switch that cuts or attenuates the
blue and green pins' signals? I'm not familiar with marine standards, but I know that red is a good
color for not affecting night vision. Not exactly a software solution, but it's also the simplest
and most general... I also happen to know it works from when I had to use a monitor with a bad blue
pin. The captain may also appreciate a nice beefy physical switch instead of having to shade the
monitor in full sunlight to be able to see it well enough to get it out of night mode.

Robert

"anthony" <an*******@controlengineer.com> wrote in message
news:u$*************@TK2MSFTNGP15.phx.gbl...
this one is really a challenge to me.

the application i developed in VB.NET 2003 runs on marine boat, the
application has many screens and controls. On a marine boat at night, only
dark cyan (or similar) color must be used on display (much like the radar
display) otherwise the captain will be blinded by the bright colors.

When at night, the user clicks on a button to turn the application into
night mode. I do not want to go through all the objects (over 1000) to
change each color, I am thinking that maybe I can change the palette of
Windows or VB, the computer they are using is designated to run my
application only, so it will not affect other application.

Is there a way i can change for example the definition of
SystemColors.Control.Yellow to SystemColors.Control.DarkCyan at night mode
and return to normal on day mode?
Thanks in advance.

Nov 21 '05 #7
You could cycle through the controls collection of the form and modify all
the controls that way. If you do it static this way you only have to check
if the control is a type you want to change. Have every form pass in it's
controls and you have it solved with only writing one function.

Public Class ColorChange
Pulblic Static Sub NightMode(byref Ctrs as Collection)
dim Ctr as Control
For each ctr in ctrs
if ctr typeof ...... then 'forget the code to check if the type
is the same

end if
next
End Sub
End Class

Hope it helps some..
Chris
"anthony" <an*******@controlengineer.com> wrote in message
news:u$*************@TK2MSFTNGP15.phx.gbl...
this one is really a challenge to me.

the application i developed in VB.NET 2003 runs on marine boat, the
application has many screens and controls. On a marine boat at night,
only
dark cyan (or similar) color must be used on display (much like the radar
display) otherwise the captain will be blinded by the bright colors.

When at night, the user clicks on a button to turn the application into
night mode. I do not want to go through all the objects (over 1000) to
change each color, I am thinking that maybe I can change the palette of
Windows or VB, the computer they are using is designated to run my
application only, so it will not affect other application.

Is there a way i can change for example the definition of
SystemColors.Control.Yellow to SystemColors.Control.DarkCyan at night mode
and return to normal on day mode?
Thanks in advance.

Nov 21 '05 #8
Thanks for all your suggestions, I am trying each one right now, I found the
API working like this:

Private Declare Function SetSysColors Lib "user32" _

(ByVal nChanges As Integer, ByRef lpSysColor As Integer, ByRef lpColorValues
As Integer) As Integer

Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As
Long

Const COLOR_SCROLLBAR = 0 'The Scrollbar colour

Const COLOR_BACKGROUND = 1 'Colour of the background with no wallpaper

Const COLOR_ACTIVECAPTION = 2 'Caption of Active Window

Const COLOR_INACTIVECAPTION = 3 'Caption of Inactive window

Const COLOR_MENU = 4 'Menu

Const COLOR_WINDOW = 5 'Windows background

Const COLOR_WINDOWFRAME = 6 'Window frame

Const COLOR_MENUTEXT = 7 'Window Text

Const COLOR_WINDOWTEXT = 8 '3D dark shadow (Win95)

Const COLOR_CAPTIONTEXT = 9 'Text in window caption

Const COLOR_ACTIVEBORDER = 10 'Border of active window

Const COLOR_INACTIVEBORDER = 11 'Border of inactive window

Const COLOR_APPWORKSPACE = 12 'Background of MDI desktop

Const COLOR_HIGHLIGHT = 13 'Selected item background

Const COLOR_HIGHLIGHTTEXT = 14 'Selected menu item

Const COLOR_BTNFACE = 15 'Button

Const COLOR_BTNSHADOW = 16 '3D shading of button

Const COLOR_GRAYTEXT = 17 'Grey text, of zero if dithering is used.

Const COLOR_BTNTEXT = 18 'Button text

Const COLOR_INACTIVECAPTIONTEXT = 19 'Text of inactive window

Const COLOR_BTNHIGHLIGHT = 20 '3D highlight of button

Const COLOR_2NDACTIVECAPTION = 27 'Win98 only: 2nd active window color

Const COLOR_2NDINACTIVECAPTION = 28 'Win98 only: 2nd inactive window color

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

Dim col As Long, t As Long

'Get the caption's active color

col = GetSysColor(COLOR_BACKGROUND)

'Change the active caption's color to red

t = SetSysColors(1, COLOR_BACKGROUND, RGB(255, 0, 0))

MsgBox("The old title bar color was" + Str$(col) + " and is now" +
Str$(GetSysColor(COLOR_ACTIVECAPTION)))

End Sub


Nov 21 '05 #9
Anthony,
The definitions should be:

Private Declare Function SetSysColors Lib "user32" _
(ByVal nChanges As Integer, ByVal lpSysColor() As Integer, _
ByVal lpColorValues() As Integer) As Boolean

Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As
Integer) _
As Integer

Rather then use a list of disparate constants for an API, I normally create
an Enum, something like:

Public Enum SystemColor As Integer
ScrollBar = 0 'The Scrollbar colour
BackGround = 1 'Colour of the background with no wallpaper
ActiveCaption = 2 'Caption of Active Window
InactiveCaption = 3 'Caption of Inactive window
Menu = 4 'Menu
Window = 5 'Windows background
WindowFrame = 6 'Window frame
MenuText = 7 'Window Text
WindowText = 8 '3D dark shadow (Win95)
CaptionText = 9 'Text in window caption
ActiveBorder = 10 'Border of active window
InactiveBorder = 11 'Border of inactive window
AppWorkspace = 12 'Background of MDI desktop
Highlight = 13 'Selected item background
HighlightText = 14 'Selected menu item
BtnFace = 15 'Button
BtnShadow = 16 '3D shading of button
GrayText = 17 'Grey text, of zero if dithering is used.
BtnText = 18 'Button text
InactiveCaptionText = 19 'Text of inactive window
BtnHightList = 20 '3D highlight of button
SecondActiveCatpion = 27 'Win98 only: 2nd active window color
SecondInactiveCaption = 28 'Win98 only: 2nd inactive window color
End Enum

Private Declare Function SetSysColors Lib "user32" (ByVal nChanges As
Integer, ByVal lpSysColor() As SystemColor, ByVal lpColorValues() As
Integer) As Integer

Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As
SystemColor) As Integer

As this gives intellisense on the API call itself, and neatly encapsulates
the constants in a single type...

Hope this helps
Jay
"anthony" <an*******@controlengineer.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Thanks for all your suggestions, I am trying each one right now, I found
the
API working like this:

Private Declare Function SetSysColors Lib "user32" _

(ByVal nChanges As Integer, ByRef lpSysColor As Integer, ByRef
lpColorValues
As Integer) As Integer

Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long)
As
Long

Const COLOR_SCROLLBAR = 0 'The Scrollbar colour

Const COLOR_BACKGROUND = 1 'Colour of the background with no wallpaper

Const COLOR_ACTIVECAPTION = 2 'Caption of Active Window

Const COLOR_INACTIVECAPTION = 3 'Caption of Inactive window

Const COLOR_MENU = 4 'Menu

Const COLOR_WINDOW = 5 'Windows background

Const COLOR_WINDOWFRAME = 6 'Window frame

Const COLOR_MENUTEXT = 7 'Window Text

Const COLOR_WINDOWTEXT = 8 '3D dark shadow (Win95)

Const COLOR_CAPTIONTEXT = 9 'Text in window caption

Const COLOR_ACTIVEBORDER = 10 'Border of active window

Const COLOR_INACTIVEBORDER = 11 'Border of inactive window

Const COLOR_APPWORKSPACE = 12 'Background of MDI desktop

Const COLOR_HIGHLIGHT = 13 'Selected item background

Const COLOR_HIGHLIGHTTEXT = 14 'Selected menu item

Const COLOR_BTNFACE = 15 'Button

Const COLOR_BTNSHADOW = 16 '3D shading of button

Const COLOR_GRAYTEXT = 17 'Grey text, of zero if dithering is used.

Const COLOR_BTNTEXT = 18 'Button text

Const COLOR_INACTIVECAPTIONTEXT = 19 'Text of inactive window

Const COLOR_BTNHIGHLIGHT = 20 '3D highlight of button

Const COLOR_2NDACTIVECAPTION = 27 'Win98 only: 2nd active window color

Const COLOR_2NDINACTIVECAPTION = 28 'Win98 only: 2nd inactive window color

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

Dim col As Long, t As Long

'Get the caption's active color

col = GetSysColor(COLOR_BACKGROUND)

'Change the active caption's color to red

t = SetSysColors(1, COLOR_BACKGROUND, RGB(255, 0, 0))

MsgBox("The old title bar color was" + Str$(col) + " and is now" +
Str$(GetSysColor(COLOR_ACTIVECAPTION)))

End Sub

Nov 21 '05 #10
It's a shame that the values for the KnownColor enumeration in
System.Drawing do not match those required for the SetSysColors
function. Then you wouldn't have had to create your own enum.

Nov 21 '05 #11
Chris,
Unfortunately KnownColor has significantly more values then what
SetSysColors expects, even if the "system color" subrange of KnownColor
matched, there would be too great a chance of sending invalid arguments to
SetSysColors if you used the KnownColor enum directly!

Or were you thinking of defining the SystemColor enum in terms of
KnownColor?

' This will not work correctly! for the reason you gave
Public Enum SystemColor As Integer
ScrollBar = KnownColor.ScrollBar
...
End Enum

I use the define my enum in terms of another enum when it makes sense, for
example defining a class library that encapsulates a COM object, if I need
to "expose" one of the COM object's enums, I will define my enum in terms of
the COM object's enum, to prevent consumers of my class library from being
coupled to the COM class library also...

Hope this helps
Jay

"Chris Dunaway" <du******@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
It's a shame that the values for the KnownColor enumeration in
System.Drawing do not match those required for the SetSysColors
function. Then you wouldn't have had to create your own enum.

Nov 21 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

42
2926
by: Frank Buss | last post by:
I've setup a challenge, mainly for C++, Java and Lisp, but every other language is welcome: http://www.frank-buss.de/challenge/index.html There is nothing to win, but I hope there will be some...
8
1700
by: Frank Buss | last post by:
A new challenge: http://www.frank-buss.de/marsrescue/index.html Have fun! Now you can win real prices. -- Frank Buß, fb@frank-buss.de http://www.frank-buss.de, http://www.it4-systems.de
0
1201
by: Richard Jones | last post by:
The date for the second PyWeek challenge has been set: Sunday 26th March to Sunday 2nd April (00:00UTC to 00:00UTC). The PyWeek challenge invites entrants to write a game in one week from...
0
1222
by: richard | last post by:
The date for the second PyWeek challenge has been set: Sunday 26th March to Sunday 2nd April (00:00UTC to 00:00UTC). The PyWeek challenge invites entrants to write a game in one week from...
11
1652
by: CMM | last post by:
First let me say that maybe I'm having a "duh" moment and perhaps I'm missing something... but it seems to me that no one thing in the System.Collections namespace (even in .NET 2.0) even comes...
78
4548
by: wkehowski | last post by:
The python code below generates a cartesian product subject to any logical combination of wildcard exclusions. For example, suppose I want to generate a cartesian product S^n, n>=3, of that...
2
4691
by: donovan | last post by:
OK, so I know that there has been a lot of discussion on this topic, but none of the answers have been satisfactory. Therefore there seems to be only one thing to do: issue a challenge to all of...
3
1453
by: Thierry | last post by:
For those interested in <b>programming riddles</b>, I would like to announce a new programming challenge I'm just launching at http://software.challenge.googlepages.com This challenge is in its...
0
1314
by: Richard Jones | last post by:
The fifth PyWeek is only a month away. Come along and join the fun: write a video game in a week! There's some really interesting new libraries that have popped up recently. Have a gander on the...
80
2985
by: jacob navia | last post by:
Several people in this group argue that standard C is not portable since there are no compilers for it, etc. I propose this program in Standard C, that I have compiled in several OSes to test if...
0
7218
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7370
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7021
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5035
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1532
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
409
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.