How to grey/blur screen, while own window is on top?
How to grey/blur screen, while own window is on top?
Some years ago, i had a nice source example but i am not really sure how to search for it and how it exactly worked.
Afaik it was a nice Win32 API, which greyed or blured all the shown elements on your monitor (dektop, all windows, taskbar i.e.) and brining your own window original to the front.
In general it looked something like: Create an 50% black color transparent (and maybe blured) borderless fullscreen window to the top of the screen and bringing your own window to the front of the greyed/blurry one. I think it was a special WIn32 API call with fading in/out. Someone an idea? thanks
PS: I am not sure if it was or required something with DWS or not...
Afaik it was a nice Win32 API, which greyed or blured all the shown elements on your monitor (dektop, all windows, taskbar i.e.) and brining your own window original to the front.
In general it looked something like: Create an 50% black color transparent (and maybe blured) borderless fullscreen window to the top of the screen and bringing your own window to the front of the greyed/blurry one. I think it was a special WIn32 API call with fading in/out. Someone an idea? thanks
PS: I am not sure if it was or required something with DWS or not...
va!n aka Thorsten
Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
Re: How to grey/blur screen, while own window is on top?
Hi
Code: Select all
ExamineDesktops()
Procedure Fake(x,y,WW,WH)
CreateImage(0,WW,WH)
hDC = StartDrawing(ImageOutput(0))
BitBlt_(hDC,0,0,WW,WH,GetDC_(GetDesktopWindow_()), x,y, #SRCCOPY)
StopDrawing()
StartDrawing(ImageOutput(0))
For x = 0 To WW - 1
For y = 0 To WH - 1
color = Point(x, y)
gray = (Red(color) + Green(color) + Blue(color)) / 3
gray = RGB(gray, gray, gray)
Plot(x, y, gray)
Next y
Next x
StopDrawing()
EndProcedure
WW = DesktopWidth(0)
WH = DesktopHeight(0)
OpenWindow(0,0,0,WW,HH,"",#PB_Window_BorderLess)
Fake(0,0,WW,WH)
ImageGadget(0,0,0,WW,HH,ImageID(0))
;DisableGadget(0,1)
SetWindowState(0,#PB_Window_Maximize)
OpenWindow(1,0,0,800,600,"",#PB_Window_SystemMenu |#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget| #PB_Window_ScreenCentered,WindowID(0))
StringGadget(1,10,10, 200,24,"",#ES_CENTER)
ButtonGadget(2,10,40,80,22,"Exit")
SetCursorPos_( WindowX(1,#PB_Window_FrameCoordinate)+100, WindowY(1,#PB_Window_FrameCoordinate)+100)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #WM_MOUSEMOVE
x = DesktopMouseX()
y = DesktopMouseY()
If x > WindowX(1,#PB_Window_FrameCoordinate) And x < WindowX(1,#PB_Window_FrameCoordinate) + WindowWidth(1) And y > WindowY(1,#PB_Window_FrameCoordinate) And y < WindowY(1,#PB_Window_FrameCoordinate) + WindowHeight(1)
ResizeWindow(0,0,0,WW,WH)
Else
ResizeWindow(0,0,0,0,0)
EndIf
Case #PB_Event_Gadget
Select EventGadget()
Case 1
Case 2
EndSelect
EndSelect
Until Quit =1
Egypt my love
Re: How to grey/blur screen, while own window is on top?
@Rashad:
Thanks for the code. Sure, this would be "faked" solution.
But as far as i remember, there was / or still is a Win32 API call / function doing this.
@all
I think the same effect was seen on an older Windows version, when the shutdown-dialog was shown.
However, i can find something on the web until now.
Edited:
I found two screenshots on the web showing something simular to what i am searching for as Win32 API function.
http://winsupersite.com/site-files/wins ... _pre04.gif
http://www.gamepc.com/images/labs/rev-x ... downLG.jpg
http://upload.wikimedia.org/wikipedia/e ... 7_flip.png
http://blogs.windows.com/cfs-file.ashx/ ... 5CE303.png
I think there was a blurry effect version too.
Thanks for the code. Sure, this would be "faked" solution.
But as far as i remember, there was / or still is a Win32 API call / function doing this.
@all
I think the same effect was seen on an older Windows version, when the shutdown-dialog was shown.
However, i can find something on the web until now.
Edited:
I found two screenshots on the web showing something simular to what i am searching for as Win32 API function.
http://winsupersite.com/site-files/wins ... _pre04.gif
http://www.gamepc.com/images/labs/rev-x ... downLG.jpg
http://upload.wikimedia.org/wikipedia/e ... 7_flip.png
http://blogs.windows.com/cfs-file.ashx/ ... 5CE303.png
I think there was a blurry effect version too.
va!n aka Thorsten
Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
Re: How to grey/blur screen, while own window is on top?
Nobody an idea? 

va!n aka Thorsten
Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
Re: How to grey/blur screen, while own window is on top?
Something here?
http://www.purebasic.fr/english/viewtopic.php?t=25616
I tried with no luck with the desktop so far.
http://www.purebasic.fr/english/viewtopic.php?t=25616
I tried with no luck with the desktop so far.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Re: How to grey/blur screen, while own window is on top?
Start with
Code: Select all
hWnd.l = OpenWindow(0,0,0,0,0, "", #PB_Window_Maximize | #PB_Window_BorderLess)
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
Re: How to grey/blur screen, while own window is on top?
Thanks Thunder93, that's perfect! 

I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: How to grey/blur screen, while own window is on top?
Not sure exactly what you're looking for, here's something to try:
Code: Select all
Global quit = 0
Procedure Ask()
hWnd.l = OpenWindow(1,0,0,0,0, "", #PB_Window_Maximize | #PB_Window_BorderLess)
SetWindowLongPtr_(hwnd, #GWL_EXSTYLE, GetWindowLongPtr_(hwnd, #GWL_EXSTYLE)|#WS_EX_LAYERED)
SetLayeredWindowAttributes_(hwnd, 0, 128, #LWA_ALPHA)
SetWindowColor(1, #Black)
StickyWindow(1, 1)
DisableWindow(1, 1)
If MessageBox_(hwnd, "Are you sure?", "Closing the application", #MB_OKCANCEL|#MB_SYSTEMMODAL) = #IDOK
quit = 1
Else
CloseWindow(1)
EndIf
EndProcedure
OpenWindow(0,0,0,640,480,"Cool Application",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
Repeat
ev= WaitWindowEvent()
Select ev
Case #PB_Event_CloseWindow
Ask()
EndSelect
Until quit
BERESHEIT
Re: How to grey/blur screen, while own window is on top?
Better remove the .lnetmaestro wrote:Code: Select all
Procedure Ask() hWnd.l = OpenWindow...

- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: How to grey/blur screen, while own window is on top?
I copied it from Thunder93... tell him to remove it! 

BERESHEIT
Re: How to grey/blur screen, while own window is on top?
Here's a simplified toggle-able version of SFSxOI's code, using PureBasic's library functions:
Code: Select all
;********************************
;
; minimum client: Windows Vista
;
;********************************
Structure DWM_BLURBEHIND
dwFlags.l
fEnable.b
hRgnBlur.l
fTransitionOnMaximized.b
EndStructure
Procedure toggleBlur()
Static blurOverlay
If blurOverlay
CloseWindow(blurOverlay)
blurOverlay = 0
ProcedureReturn #False
EndIf
wFlags = #PB_Window_Maximize | #PB_Window_BorderLess
blurOverlay = OpenWindow(#PB_Any, 0, 0, 0, 0, "", wFLags)
SetWindowColor(blurOverlay, 0)
blurBehind.DWM_BLURBEHIND
blurBehind\dwFlags = 1
blurBehind\fEnable = #True
blurBehind\fTransitionOnMaximized = #False
If OpenLibrary(0, "dwmapi.dll")
*blurFunc = GetFunction(0, "DwmEnableBlurBehindWindow")
If *blurFunc
CallFunctionFast(*blurFunc, WindowID(blurOverlay), @blurBehind)
CloseLibrary(0)
ProcedureReturn #True
EndIf
EndIf
ProcedureReturn #False
EndProcedure
Enumeration
#MainWindow
#Button
EndEnumeration
wFLags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(#Mainwindow, #PB_Any, #PB_Any, 300, 150, "Blurred Background", wFlags)
ButtonGadget(#Button, 50, 50, 200, 50, "Blur the background...")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
appQuit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case #Button
If toggleBlur()
MessageRequester("Desktop Window Manager",
"Background blurred successfully!",
#PB_MessageRequester_Ok)
toggleBlur()
EndIf
EndSelect
EndSelect
Until appQuit = 1
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 

- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: How to grey/blur screen, while own window is on top?
Maximum client: Windows 7. Unfortunately Windows 8 doesn't blur, it just whites out. Aero is gone.; minimum client: Windows Vista
BERESHEIT
Re: How to grey/blur screen, while own window is on top?
Hi
Code: Select all
SystemParametersInfo_(#SPI_GETWORKAREA, 0, @r.RECT, 0)
WW = r\right - r\left
WH = r\bottom - r\top
CreateImage(0,WW,WH)
hDC = StartDrawing(ImageOutput(0))
BitBlt_(hDC,0,0,WW,WH,GetDC_(GetDesktopWindow_()), r\left,r\top, #SRCCOPY)
StopDrawing()
StartDrawing(ImageOutput(0))
For x = 0 To WW - 1
For y = 0 To WH - 1
color = Point(x, y)
gray = (Red(color) + Green(color) + Blue(color)) / 3
gray = RGB(gray, gray, gray)
Plot(x, y, gray)
Next y
Next x
StopDrawing()
OpenWindow(0,r\left,r\top,WW,WH,"",#PB_Window_BorderLess|#PB_Window_Invisible)
myBrush = CreatePatternBrush_(ImageID(0))
SetClassLongPtr_(WindowID(0), #GCL_HBRBACKGROUND, myBrush)
;InvalidateRect_(WindowID(0),0,1)
FreeImage(0)
AnimateWindow_(WindowID(0),1500,#AW_BLEND|#AW_ACTIVATE)
OpenWindow(1,0,0,800,600,"",#PB_Window_SystemMenu |#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget| #PB_Window_ScreenCentered,WindowID(0))
StringGadget(1,10,10, 200,24,"",#ES_CENTER)
ButtonGadget(2,10,40,80,22,"Exit")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 1
Case 2
EndSelect
EndSelect
Until Quit =1
Egypt my love
Re: How to grey/blur screen, while own window is on top?
No excuses! We were taught at an very early age not to be copying from others. If you do copy from others, then their mistakes becomes yours. You must own up to your mistake!

netmaestro wrote:I copied it from Thunder93... tell him to remove it!
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
Re: How to grey/blur screen, while own window is on top?
netmaestro wrote:I copied it from Thunder93... tell him to remove it!
I copied it from MSDN!netmaestro wrote:Maximum client: Windows 7. Unfortunately Windows 8 doesn't blur, it just whites out. Aero is gone.; minimum client: Windows Vista

Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 
