Zub_Exodo
asked on
Gray Screen
NOTE: I want to do this promatically not manually.
==========================
How can I stop all the prosses on my computer and make a gray screen exactly like Windows xp?
Click Start and Turn Off you computer and wait few second you'll see what am talking about.
Sorry but I always like to explain things the best I can : ) anyone know how win xp looks like when is turning off : )
I will be happy if at list I can make the whole screen go gray exactly the same color of windows xp
it looks like black and white : ) something like that.
ASKER
For the question 1.
Sorry i forgot to explain...
I don't realy want it to stop all the prosses...
I just want it to make the desktop inaccessible to the mouse thats all
an option that i can still move the mouse but living the screen disable
and for the question 2.
The reason I want to make the grayscale effect is to make it look like the one on windows xp thats all.
Ok then. Question 1 is redundant and will be taken care of by question 2 anyway.
The program below will capture the screen for you; (beware! it looks like nothing happens, but the program IS running, and has taken over. Press <ctrl-break> to regain access to the IDE).
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --
'Create a new project, set the form's controlbox property to false, place a picturebox on the form and call it bgPic,
Option Explicit
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal Window As Long) As Long
Private Declare Function BitBlt Lib "gdi32" ( _
ByVal DestDC As Long, ByVal DestX As Long, ByVal DestY As Long, ByVal W As Long, ByVal H As Long, _
ByVal SourceDC As Long, ByVal SourceX As Long, ByVal SourceY As Long, ByVal Rop As Long) As Long
Private Sub Form_Load()
'set up a picturebox to capture the screen
bgPic.Move 0, 0, Screen.Width, Screen.Height
bgPic.AutoRedraw = True
'copy current display into picturebox
BitBlt bgPic.hDC, 0, 0, Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY, GetWindowDC(GetDesktopWind ow()), 0, 0, vbSrcCopy
'display capture over entire screen
Me.Caption = vbNullString
Me.WindowState = vbMaximized
End Sub
The program below will capture the screen for you; (beware! it looks like nothing happens, but the program IS running, and has taken over. Press <ctrl-break> to regain access to the IDE).
--------------------------
'Create a new project, set the form's controlbox property to false, place a picturebox on the form and call it bgPic,
Option Explicit
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal Window As Long) As Long
Private Declare Function BitBlt Lib "gdi32" ( _
ByVal DestDC As Long, ByVal DestX As Long, ByVal DestY As Long, ByVal W As Long, ByVal H As Long, _
ByVal SourceDC As Long, ByVal SourceX As Long, ByVal SourceY As Long, ByVal Rop As Long) As Long
Private Sub Form_Load()
'set up a picturebox to capture the screen
bgPic.Move 0, 0, Screen.Width, Screen.Height
bgPic.AutoRedraw = True
'copy current display into picturebox
BitBlt bgPic.hDC, 0, 0, Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY, GetWindowDC(GetDesktopWind
'display capture over entire screen
Me.Caption = vbNullString
Me.WindowState = vbMaximized
End Sub
To make your screen capture greyscale, there's probably a nice neat transform you can do with GDI+ or something, however I don't know what it is. The library I mentioned above at http://davidcrowell.com/PhotoTrue.aspx is free and can do it for you.
If you want a pure VB6 solution, there is one below. It is SLOW, SLOW, SLOW. It takes ~10 seconds to convert my 1280x1024 display. Looks just like Microsoft's though :-)
Add the following to the previous program, just before the line 'End Sub';
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---
Me.Show
'Make the picture greyscale
Dim x As Integer, y As Integer
Dim colour As Long
Dim red As Double, green As Double, blue As Double, grey As Double
bgPic.ScaleMode = vbPixels
For x = 0 To bgPic.ScaleWidth - 1
For y = 0 To bgPic.ScaleHeight - 1
colour = bgPic.Point(x, y)
red = colour Mod 256
green = Int(colour / 256) Mod 256
blue = Int(colour / 65536)
'convert using ITU standard
grey = Int(((red * 222) + (green * 707) + (blue * 71)) / 1000)
If grey > 255 Then grey = 255
If grey < 0 Then grey = 0
bgPic.PSet (x, y), RGB(grey, grey, grey)
Next
Next
If you want a pure VB6 solution, there is one below. It is SLOW, SLOW, SLOW. It takes ~10 seconds to convert my 1280x1024 display. Looks just like Microsoft's though :-)
Add the following to the previous program, just before the line 'End Sub';
--------------------------
Me.Show
'Make the picture greyscale
Dim x As Integer, y As Integer
Dim colour As Long
Dim red As Double, green As Double, blue As Double, grey As Double
bgPic.ScaleMode = vbPixels
For x = 0 To bgPic.ScaleWidth - 1
For y = 0 To bgPic.ScaleHeight - 1
colour = bgPic.Point(x, y)
red = colour Mod 256
green = Int(colour / 256) Mod 256
blue = Int(colour / 65536)
'convert using ITU standard
grey = Int(((red * 222) + (green * 707) + (blue * 71)) / 1000)
If grey > 255 Then grey = 255
If grey < 0 Then grey = 0
bgPic.PSet (x, y), RGB(grey, grey, grey)
Next
Next
ASKER
I like the free example of photo true...
but just by adding that single option of the grayscale...
i'll have to add the photo.dll to my project and i don't realy
want my project to be asociate with any dll file with it.
==========================
The following code is not mine i just modify few lines from the original code to make it work better...
But take a look and let me know if you can make it better.
this code don't required any dll file and is very simple and easier to make it work.
Add to a Form... 1 CommonDialog Control, Then paste this in Filters => All Pictures | *.gif; *.bmp; *.jpg
Next add 2 PictureBox, and 2 Buttoms...
Now paste this code in the Form
Option Explicit
Private Type RGBType
r As Byte
g As Byte
b As Byte
End Type
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Public Sub GrayScale()
Dim x As Long, y As Long
Dim udtRGB As RGBType
Dim AverageColor As Integer
Dim AddedValue As Integer
For y = 0 To Picture1.Height Step 15
For x = 0 To Picture1.Width Step 15
AverageColor = 0
AddedValue = 0
udtRGB = LongToRGB(GetPixel(Picture
AverageColor = AverageColor + udtRGB.r
AddedValue = AddedValue + 1
AverageColor = AverageColor + udtRGB.g
AddedValue = AddedValue + 1
AverageColor = AverageColor + udtRGB.b
AddedValue = AddedValue + 1
If AverageColor < 0 Then AverageColor = 0
AverageColor = (AverageColor / AddedValue)
DoEvents
SetPixel Picture2.hdc, x / 15, y / 15, RGB(AverageColor, AverageColor, AverageColor)
Next x
Next y
End Sub
Private Function LongToRGB(iColor As Long) As RGBType
Dim temp As Long
temp = (iColor And 255)
LongToRGB.r = temp And 255
temp = Int(iColor / 256)
LongToRGB.g = temp And 255
temp = Int(iColor / 65536)
LongToRGB.b = temp And 255
End Function
Private Sub Command1_Click()
Call GrayScale
End Sub
Private Sub Command2_Click()
Dim filename As String
On Error Resume Next
CommonDialog1.ShowOpen
filename = CommonDialog1.filename
Picture1.Picture = LoadPicture(filename)
End Sub
Private Sub Form_Load()
Command1.Caption = "Make GrayScale"
Command2.Caption = "Load picture"
End Sub
ASKER
I have seen some utilities that do just like i want to do
TuneUp Utillity is one of then : ) it call the shell32.dll ... I wonder how it does that
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yeah you code work fine...
But it take a while to load or show the GrayScale
The code that i showed you load faster and you can see it when is loading the picture
The code of yours...
does it have an other way to make it faster?
the idea in the one i showed you it was based in the way microsoft load his grayscale
the better style in microsoft is the fade effect that mine doesn't have
The better style in Microsoft's is also due to the different weightings that are given to each colour. The human eye perceives more detail in green colour ranges than blue or red. The ITU method results in a grayscale image with better illuminosity.
Sorry. I don't have enough spare time to play around with making this any faster.
Sorry. I don't have enough spare time to play around with making this any faster.
ASKER
Ok Thanks
You can't stop ALL the processes on your computer, although you can stop most of them.
Use WMI to do it rather than use the WinAPI to enumerate processes and have to deal with callbacks.
Question #2 - grey screen
Windows XP makes the screen gradually become greyscale instead of full colour when you choose 'turn off'. (except for the 'turn off' dialog).
You can use bitblt to capture the whole screen withough any problems. Display it in on a form that is sized so the client area takes up the whole screen. Then you just need a timer to call something like the make greyscale function in http://davidcrowell.com/Download/ptrue2.zip to gradually change the image.