Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good day here, am happy to be part of this forum. For some times now I have been helped with resources, articles, questions and answers to posts from this forum and that was what prompted me to join. Now that I am part of the forum, I know that I will enjoy more of your help.
This will be my first time of asking questions since I joined this group of programmers, therefore I may not know the rules but you can correct me should I have any 'commit'. Thanks.
I was working on a project that most of you will call 'the simplest project' 2 or 3weeks ago and since then I've been having tough time with it. The project is what I called NIGHTMODE. I wanted to reduce the brightness of my laptop at night (because that is the best available time for me to code) but the lowest brightness setting was still too bright then I thought of overlaying a transparent black windows form which will stay on top of every other window and will be invisible to MouseClick. I started by opening a form called NiteMode then import user32.dll for handling the transparency and the click through of the windows form and set the windowState to maximize and TopMost property to true but it will not always be on top, then I defined a thread and assigned it a method inside which I used a while-loop to continuously set the form's TopMost property to true every half of a second. I opened another form(mainNiteMode) which contain a progressBar to set the opacity of the first form(NiteMode) and a checkBox to switch on and off, i.e to call NitMode.Show() and NiteMode.Hide() of the first form(NiteMode) which I instantiated as a type called 'niteform'. I handled the checkBox's checkChanges event, inside which I called niteform.Show() if its checked.
Now the problem was that control was not returned to mainNiteMode whenever I call niteform.Show() because I override the NiteMode's onShown and inside it I called thread.Start(). Meaning that the seconds thread is not returning control to the first because of the while-loop its running.
I have tried several things but the same problem kept on repeating it self.
I even tried to create the instance of NiteMode form on another thread from the mainNiteMode form but it will not work, I try to create a backgroundworker thread instead and instantiate the NiteMode from a method called by the worker thread but I encountered same problem. Please what can I do? Thanks so much for your usual help.
Posted

1 solution

CodeProject is your friend: "Setting Screen Brightness in C#: [^].

Are you aware of the free FLux software ?: [^].

Frankly, I think the idea of putting a semi-transparent window on top of all the other windows to darken the screen is ... very strange ... I would look for another technique.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900