473,803 Members | 3,195 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Turning monitor off- only works on some machines

I'm trying to get some VB.NET code to turn off the backlight of the LCD
monitor on a machine we've built.

The code

**********
' For switching off the backlight
Private Declare Function SendMessage Lib "user32" Alias "SendMessag eA"
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam
As Long) As Long
Const SC_MONITORPOWER As Long = &HF170&
Const MONITOR_ON As Long = -1&
Const MONITOR_OFF As Long = 2&
Const WM_SYSCOMMAND As Long = &H112

SendMessage Me.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER , MONITOR_OFF
************

works on a desktop machine running XP Home and a CRT monitor, however on a
laptop running XP Pro, a desktop machine with LCD monitor and XP pro and a
test machine with LCD monitor running Windows 2000 it simply fails silently.
It is the same code copied across, so there is no possibility of a typing
error. On both misbehaving machines, I've verified that if I set the power
management from Display Properties to turn off the monitor, the display and
backlight do indeed switch off. The LCD monitor is integrated into the
Win2000 machine so I cannot see if this is some bizarre problem with LCD and
CRT displays.

Googling has not helped, so I'm hoping someone here can cast some light on
this.

--
Dr. Craig Graham, Software Engineer
Advanced Analysis and Integration Limited, UK. http://www.aail.co.uk/

Nov 20 '05 #1
4 5822
* "Craig Graham" <cr***@twolip s-translations.co .uk> scripsit:
I'm trying to get some VB.NET code to turn off the backlight of the LCD
monitor on a machine we've built.

The code

**********
' For switching off the backlight
Private Declare Function SendMessage Lib "user32" Alias "SendMessag eA"
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam
As Long) As Long
Replace all 'As Long' with 'As Int32', 'hWnd' should be declared as 'IntPtr'.
Const SC_MONITORPOWER As Long = &HF170&
Const MONITOR_ON As Long = -1&
Const MONITOR_OFF As Long = 2&
Const WM_SYSCOMMAND As Long = &H112
Dito.

SendMessage Me.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER , MONITOR_OFF
************


--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
I have the same problem with Visual Basic 6.0 and the declaration is the same
How can i do to solve my problem? Somethimes works, but i need to use it to turn on the monitor after the switching off by OS

Thank

----- Herfried K. Wagner [MVP] wrote: ----

* "Craig Graham" <cr***@twolip s-translations.co .uk> scripsit
I'm trying to get some VB.NET code to turn off the backlight of the LC
monitor on a machine we've built
The cod
********* ' For switching off the backligh
Private Declare Function SendMessage Lib "user32" Alias "SendMessag eA
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lPara
As Long) As Lon


Replace all 'As Long' with 'As Int32', 'hWnd' should be declared as 'IntPtr'
Const SC_MONITORPOWER As Long = &HF170&> Const MONITOR_ON As Long = -1&> Const MONITOR_OFF As Long = 2&> Const WM_SYSCOMMAND As Long = &H11


Dito
SendMessage Me.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER , MONITOR_OF

***********


--
Herfried K. Wagner [MVP
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
* "=?Utf-8?B?QWxleA==?=" <al************ ******@sella.it > scripsit:
I have the same problem with Visual Basic 6.0 and the declaration is the same.
How can i do to solve my problem? Somethimes works, but i need to use it to turn on the monitor after the switching off by OS.


I don't understand your problem. VB.NET isn't just a new version of the
Visual Basic Classic programming language. It's a new programming
language and code which works in VB Classic often won't work in VB.NET.
The declaration for 'SendMessage' is different in VB.NET and in VB
Classic. Which programming language are you using?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Actually, I 'm using Visual Basic 6.0, but the problem is the same.
My declaration is:
Private Declare Function SendMessage Lib "user32" Alias "SendMessag eA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_SYSCOMMAND = &H112&
Private Const SC_MONITORPOWER = &HF170&

The function doesn't work because it try to power on the monitor, but after few milliseconds come back to power off.
After stand by of monitor, how can I resume the monitor to power on?
Which API can I use to solve my problem?

Thanks

----- Herfried K. Wagner [MVP] wrote: -----

* "=?Utf-8?B?QWxleA==?=" <al************ ******@sella.it > scripsit:
I have the same problem with Visual Basic 6.0 and the declaration is the same.
How can i do to solve my problem? Somethimes works, but i need to use it to turn on the monitor after the switching off by OS.


I don't understand your problem. VB.NET isn't just a new version of the
Visual Basic Classic programming language. It's a new programming
language and code which works in VB Classic often won't work in VB.NET.
The declaration for 'SendMessage' is different in VB.NET and in VB
Classic. Which programming language are you using?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5

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

Similar topics

13
4231
by: Lee | last post by:
Hello All, First of all I would like to say thank you for all of the help I have received here. I have been teaching myself Access for about 4 years now and I've always been able to find a solution here - until now. This one is driving me crazy. I am making my first attempt at creating a runtime application. I am using Access 2003 Developer Extensions. Initially I developed the database without planning on creating a runtime app...
2
3312
by: Jack David | last post by:
Using the code below I am able to monitor a single directory for a new file and then kick-off a process to deal with the file. The question is??? How would I modify this code to be able to monitor a couple of different directories and based upon the directory where the new file is created kick-off a process Example: File A in Directory B starts process C
7
13468
by: Dave | last post by:
Is there a way to query the monitor status, to know if it is on or off in C#? I found that WM_SYSCOMMAND is sent to WndProc when the monitor goes on and off but im not sure to find out if that message is always just about the monitor. Thanks for any help.
1
3555
by: Micah Hastings | last post by:
The last time I did this was back in Visual Basic 6. Now I am using VB.NET 2005. When I use my code now, it turns off the monitor just fine. However when I move my mouse the monitor comes back on. Back in VB6, I was able to turn off the monitor and it wouldn't come back on until I issued the API command to turn in back on regardless of mouse movement. How do I accomplish this in VB.NET?
0
1803
by: Robert | last post by:
After failing on a yield/iterator-continuation problem in Python (see below) I tried the Ruby (1.8.2) language first time on that construct: The example tries to convert a block callback interface (Net::FTP.retrbinary) into a read()-like iterator function in order to virtualize the existing FTP class as kind of file system. 4 bytes max per read in this first simple test below. But it fails on the second continuation with ThreadError after...
4
4525
by: NormD | last post by:
I am running Windows XP, and IE version 6.0.2900 on my desktop. It has the ..Net Framework Service Pack 1 installed on it. Security was turned off on the machine using "CASPOL -s off". A .Net windows application has been deployed on a Win 2003 web server. When I try to launch the application through auto deploy (https://www.myserver.com/myApp.exe), I'm being prompted "Do you want to run or save this file?" with Run/Save/Cancel options....
0
1534
by: Ed | last post by:
I want to know when the screensaver has kicked in on my monitor so that I can turn off the desk light in my office. Under XP it has worked great. I use the following to check if screensaver is running: '' Check if Screen Saver is Running i = WinApi.SystemParametersInfo(114, 0, SS, 0) 'SPI_GETSCREENSAVERRUNNING
13
5979
by: Cross | last post by:
I am developing an application that will show movies. When you wach a movie, you do not want the Power Option "Turn off monitor" to be anabled. Is there anyway to fix this from VB.net? (note that I am not talking about the screen saver, that is something else). I'm very thankfull for answers, but plea, no guesses this time.
5
14817
by: jbenner | last post by:
I have opened a PMR for this with IBM, and am not asking for advice from the DB2 DBA community. I am posting this as an FYI that DB2 Health Monitor, even at the latest version of DB2, still can cause huge problems with slow connect times and heavy resource locking in high concurrency / high transaction volume environments. I have an OLTP with 30-90 transactions per second activity, and start of Health Monitor every 2 hours was crashing our...
6
1592
by: Rain | last post by:
Hi, I noticed the other day when I was trying to optimise the traffic on a particular web page that it had significant viewstate even though I had turned it off for most of the controls. So in a bold step I decided to attempt to set viewstate on the form itself off which had a massive impact on the viewstate like 80K to 15k. So my question is what is the significance of turning off the viewstate for the form and what information...
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10542
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10289
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9119
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7600
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4274
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 we have to send another system
2
3795
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2968
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.