cyberlive Posted May 22, 2014 Share Posted May 22, 2014 Good day All - Before I have the main GUI for an application presented to the user, i have a msgbox with a yesno option for the user to accept or decline. I have that msgbox set with the setforeground, but I am struggling with how (if possible) to blur out the background of the rest of the screen size so that only the msgbox is in focus. Thanks as always -- Link to comment Share on other sites More sharing options...
UEZ Posted May 22, 2014 Share Posted May 22, 2014 (edited) Try this:#include <Screencapture.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Message("Is this what you are looking for?") _GDIPlus_Shutdown() Func Message($sText, $sHeader = "Question", $iFlag = 4 + 32 + 262144, $iBlur = 5) ;coded by UEZ Local Const $iW = @DesktopWidth, $iH = @DesktopHeight Local $hGui = GUICreate("", $iW, $iH, 0, 0, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_APPWINDOW)) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui) Local $hHBitmap = _ScreenCapture_Capture("", 0, 0, $iW - 1, $iH - 1, 0) Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) _WinAPI_DeleteObject($hHBitmap) Local $hEffect = _GDIPlus_EffectCreateBlur($iBlur) _GDIPlus_BitmapApplyEffect($hBitmap, $hEffect) GUISetState(@SW_SHOWNA) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iW, $iH) Local $iRet = MsgBox($iFlag, $sHeader, $sText, 0, $hGui) _GDIPlus_EffectDispose($hEffect) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphics) GUIDelete($hGui) Return $iRet EndFuncRuns only with MS Vista or higher operating system and latest AutoIt version! Br,UEZ Edited May 22, 2014 by UEZ mesale0077 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
cyberlive Posted May 22, 2014 Author Share Posted May 22, 2014 Thanks UEZ I just tried that and that is the effect i am after. A little deeper perhaps, but is there a way to set a 'degree' to which the out of focus effect is displayed? I am taking a look through the documentation on $hEffect, $hBitmap, etc... but do not see it defined. Link to comment Share on other sites More sharing options...
JohnOne Posted May 22, 2014 Share Posted May 22, 2014 Local $hEffect = _GDIPlus_EffectCreateBlur(20) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
UEZ Posted May 22, 2014 Share Posted May 22, 2014 Look at _GDIPlus_EffectCreateBlur in the help file to set the blur radius. Variables are variables and not documented in the help file - that wouldn't make any sense.Br,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
cyberlive Posted May 22, 2014 Author Share Posted May 22, 2014 Thank you JohnOne and UEZ. That did it. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 22, 2014 Moderators Share Posted May 22, 2014 UEZ,Splendid! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
UEZ Posted May 22, 2014 Share Posted May 22, 2014 (edited) Thanks Melba23.I made some small modifications to the code above.@cyberlive: you are welcome. The code above doesn't support multi monitors. Homework: modify the code that it supports multi monitors. Br,UEZ Edited May 22, 2014 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Solution UEZ Posted May 23, 2014 Solution Share Posted May 23, 2014 (edited) The GDI+ v1.1 built-in blur code is too slow and the effect doesn't look very well at least on my Win 8.1 notebook.I changed the code a little bit using the blur code from eukalyptus and added an option to blur-in (by default not enabled) the image.The code doesn't require GDI+ v1.1 and should run also on WinXP (not tested).expandcollapse popup#include <GDIPlus.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() MessageBoxBlurBackground("Is this what you are looking for?") _GDIPlus_Shutdown() Func MessageBoxBlurBackground($sText, $sHeader = "Question", $iFlag = 4 + 32 + 262144, $fBlur = 0.15, $bBlurIn = False, $iTimeOut = 0) ;coded by UEZ Local $hFullScreen = WinGetHandle("[TITLE:Program Manager;CLASS:Progman]"), $aFullScreen = WinGetPos($hFullScreen) Local Const $iW = $aFullScreen[2], $iH = $aFullScreen[3] Local $hGui = GUICreate("", $iW, $iH, $aFullScreen[0], $aFullScreen[1], $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_APPWINDOW)) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui) ;capture full screen Local $hWnd = _WinAPI_GetDesktopWindow() Local $hDDC = _WinAPI_GetDC($hWnd) Local $hCDC = _WinAPI_CreateCompatibleDC($hDDC) Local $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDDC, $iW, $iH) _WinAPI_SelectObject($hCDC, $hHBitmap) _WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, $aFullScreen[0], $aFullScreen[1], $SRCCOPY) ;copy captured screen to bitmap _WinAPI_ReleaseDC($hWnd, $hDDC) _WinAPI_DeleteDC($hCDC) Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) ;convert GDI bitmap to GDI+ bitmap _WinAPI_DeleteObject($hHBitmap) Local $hBmp_GDIPlus_BitmapBlurred, $i Switch $bBlurIn Case True GUISetState(@SW_SHOWNA) For $i = 2 To 7 Step 0.5 $hBmp_GDIPlus_BitmapBlurred = _GDIPlus_BitmapBlur($hBitmap, $iW, $iH, 1 / $i) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBmp_GDIPlus_BitmapBlurred, 0, 0, $iW, $iH) ;copy blurred image to GUI _GDIPlus_BitmapDispose($hBmp_GDIPlus_BitmapBlurred) Next Case Else $hBmp_GDIPlus_BitmapBlurred = _GDIPlus_BitmapBlur($hBitmap, $iW, $iH, $fBlur) GUISetState(@SW_SHOWNA) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBmp_GDIPlus_BitmapBlurred, 0, 0, $iW, $iH) ;copy blurred image to GUI _GDIPlus_BitmapDispose($hBmp_GDIPlus_BitmapBlurred) EndSwitch Local $iRet = MsgBox($iFlag, $sHeader, $sText, $iTimeOut, $hGui) ;cleanup resources _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphics) GUIDelete($hGui) Return $iRet EndFunc Func _GDIPlus_BitmapBlur($hBitmap, $iW, $iH, $fScale = 0.15, $qual = 6); by eukalyptus Local Const $hGraphics = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow()) Local Const $hBmpSmall = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics) Local Const $hGfxSmall = _GDIPlus_ImageGetGraphicsContext($hBmpSmall) _GDIPlus_GraphicsSetPixelOffsetMode($hGfxSmall, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) Local Const $hBmpBig = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics) Local Const $hGfxBig = _GDIPlus_ImageGetGraphicsContext($hBmpBig) _GDIPlus_GraphicsSetPixelOffsetMode($hGfxBig, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) _GDIPlus_GraphicsScaleTransform($hGfxSmall, $fScale, $fScale) _GDIPlus_GraphicsSetInterpolationMode($hGfxSmall, $qual) _GDIPlus_GraphicsScaleTransform($hGfxBig, 1 / $fScale, 1 / $fScale) _GDIPlus_GraphicsSetInterpolationMode($hGfxBig, $qual) _GDIPlus_GraphicsDrawImageRect($hGfxSmall, $hBitmap, 0, 0, $iW, $iH) _GDIPlus_GraphicsDrawImageRect($hGfxBig, $hBmpSmall, 0, 0, $iW, $iH) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBmpSmall) _GDIPlus_GraphicsDispose($hGfxSmall) _GDIPlus_GraphicsDispose($hGfxBig) Return $hBmpBig EndFunc ;==>_GDIPlus_BitmapBlurBr,UEZ Edited May 23, 2014 by UEZ dmob, Muzaiyan and FireFox 3 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now