473,406 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Display in Night Mode

I am writing a windowsform application which has to be used in both
day and night environments. In the night, the room is dark and all
controls need to be dimmed / subdued. Is there any control which can
help me do this. Or how do I do it?
Thank
Nitin
Sep 11 '08 #1
4 4381
On Thu, 11 Sep 2008 10:34:25 -0700, Maddy <mn******@gmail.comwrote:
I am writing a windowsform application which has to be used in both
day and night environments. In the night, the room is dark and all
controls need to be dimmed / subdued. Is there any control which can
help me do this. Or how do I do it?
I'm not aware of any specific controls for this purpose, nor of any
specific support in .NET for this kind of thing.

However, you might look at some of the accessibility features in Windows
generally. You can access whatever's there through p/invoke if you want
to control it from a C#/.NET program.

The thing I'm thinking of in particular is that there's a "negative,
high-contrast" mode that's useful for people with certain kinds of vision
problems. One feature of the mode is that much of the display is rendered
in black, with the user-interface itself in white or shades of gray. The
result is that a lot less of the screen is putting out light.

Even with that, in a low-light situation you would probably want to dim
the display brightness. But maybe the special display mode will help.

Again, I don't think that .NET has an API specifically to control that,
but at the very least you would be able to get at it through the normal
Windows API (sorry, don't have those details off the topof my head). It's
also possible that there's something in WMI to control it.

Pete
Sep 11 '08 #2
On Sep 11, 1:34*pm, Maddy <mniti...@gmail.comwrote:
I am writing a windowsform application which has to be used in both
day and night environments. In the night, the room is dark and all
controls need to be dimmed / subdued. Is there any control which can
help me do this. Or how do I do it?
Thank
Nitin
Hi,

There is nothing like that in the framework.

You can customize your window desktop in such a way that it displays
nicerly @ nights.
What I do not know is how you can change the theme of the windows
desktop from .NET

Alternately there are third party frameworks (like infragistics) that
allow the use of Skins (just like asp.net) in windows. This will only
affet your application
Sep 11 '08 #3
Hi Maddy,

once i had a fellow developer who had
problems with his eyes in bright rooms
and i wrote this for him. It modifies the
displays gamm ramp values and makes
it very dark. It is written in VB6 but it
should be n match to move it to C# for
you:

Private DeviceRampDefault(0 To 255, 0 To 2) As Integer
Private AdjustedDeviceRamp(0 To 255, 0 To 2) As Integer
Private Declare Function GetDeviceGammaRamp Lib "gdi32" (ByVal hdc As Long,
lpv As Any) As Long
Private Declare Function SetDeviceGammaRamp Lib "gdi32" (ByVal hdc As Long,
lpv As Any) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory"
(Destination As Any, Source As Any, ByVal Length As Long)

Private Sub CheckASGRSetGammaRamp_Click()
If Me.CheckASGRSetGammaRamp.Value = Checked Then
SetDarkGammaRamp
Else
SetDeviceGammaRamp Me.hdc, DeviceRampDefault(0, 0)
End If
End Sub

Private Sub commandASGRExit_Click()
mnuExit_Click
End Sub

Private Sub Form_Load()
Me.Caption = App.ProductName & " " & App.Major & "." & App.Minor
GetDeviceGammaRamp Me.hdc, DeviceRampDefault(0, 0)
End Sub

Private Sub Form_Unload(Cancel As Integer)
If Me.CheckASGRRestoreOnExit.Value = Checked Then
SetDeviceGammaRamp Me.hdc, DeviceRampDefault(0, 0)
End If
End Sub

Private Sub mnuAbout_Click()
Dim HelpMessage As String

HelpMessage = App.ProductName & " " & App.Major & "." & App.Minor & vbCrLf
_
& "by Kerem Gümrükcü" & vbCrLf _
& "Contact: ke*****@arcor.de"

MsgBox HelpMessage, vbOKOnly Or vbInformation Or vbApplicationModal,
App.ProductName & " " & App.Major & "." & App.Minor

End Sub
Private Function SetDarkGammaRamp()
Dim iItr As Integer
Dim lVal As Long
For iItr = 0 To 255
lVal = IntToLng(DeviceRampDefault(iItr, 0))
AdjustedDeviceRamp(iItr, 0) =
LngToInt(IntToLng(DeviceRampDefault(iItr, 0)) / 2)
AdjustedDeviceRamp(iItr, 1) =
LngToInt(IntToLng(DeviceRampDefault(iItr, 1)) / 2)
AdjustedDeviceRamp(iItr, 2) =
LngToInt(IntToLng(DeviceRampDefault(iItr, 2)) / 2)
Next iItr

SetDeviceGammaRamp Me.hdc, AdjustedDeviceRamp(0, 0)

End Function
Private Sub mnuExit_Click()
Unload Me
End Sub

Public Function IntToLng(IntVal As Integer) As Long
CopyMemory IntToLng, IntVal, 2
End Function
Public Function LngToInt(Value As Long) As Integer
CopyMemory LngToInt, Value, 2
End Function

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.codeplex.com/restarts
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."

Sep 11 '08 #4
Thanks for all the help. I am just starting to learn c# using a
project. Used Delphi earlier which had a component for this. Wont
waste time searching for a component now. Will think of something.
thanks.
Sep 12 '08 #5

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

Similar topics

3
by: JPM III | last post by:
I wrote a PHP script that allows me to post HTML entries to files on my server without going through FTP, yadda yadda. It works fine, and last night it updated both files properly. Today, it...
2
by: Kay | last post by:
This function is used to display the context of a queue. I input an integer comparing with the queue cuisine number, if cuisine number is same as the input, it shows the context. However, it cannot...
19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
13
by: Benjamin Smith | last post by:
I am controlling the display status of a table row using the following code. <TR id="CCRow" style="DISPLAY:none"> Instead of hard coding "none" above, I would like to change that value using a...
5
by: Bredahl jensen | last post by:
Hello, Is there a way to cause internet explorer to display data in full screen mode. The F11 keys does som of the job. But the tool bar remain. Any idea? Many thanks
0
by: Jonathan L. | last post by:
I've got a relatively simple scenario that I haven't been able to solve in ASP 2.0. Let's assume I have a simple foreign key relationship as demonstrated below: ------------------- ...
3
by: c676228 | last post by:
Hi everyone, I have a piece of code in sales.aspx.vb like this: Protected WithEvents Message As System.Web.UI.WebControls.Label Try ... ChartImage.ImageUrl = "ChartGenerator.aspx?" + DataStr +...
2
by: =?Utf-8?B?Z2FuZQ==?= | last post by:
Hi, In a gridview, How can i display different columns between item and edit modes. For eg. i have a sql that returns productname, categoryname, etc. In viewmode, i need to display only...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.