Jump to content

Recommended Posts

Posted

Hello, so the issue is quite simple, I need to keep child window behind the parent window in Z order. The child window will have regions clipped and other things done to it however it will serve no purpose other than cosmetics. "$WS_EX_MDICHILD, $hParent)" seemed like a simple solution however I can't get the window to stay behind parent. I've looked through the forums without any luck for this particular issue.

Couple of things:
1. No WinActivate()
2. No loops
3. No WinMove with parent

The script itself is over 17k lines with over a dozen of other windows depending on the parent so that's why the limitations from above.

I did look into creating a blur behind a specific area only however it seems it ignores the rectangle coordinates and simply applies blur behind entire window. This idea was submitted on some other forum with a different language however it didn't work there either and I can't find the link. But if anyone has a solution to applying blur to a specific area that would be even better.

 

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

Global $hParent = GUICreate("test", 600, 400, -1, -1, BitOR($WS_POPUP, $WS_BORDER), -1)
GUISetBkColor(0x202025, $hParent)
GUICtrlCreateButton("Button Left", 10, 55, 100, 20)
Global $idButton = GUICtrlCreateButton("Button Right", 190, 55, 100, 20)
GUISetState(@SW_SHOW, $hParent)

Local $tMargs = DllStructCreate("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight")
DllStructSetData($tMargs, 1, 180)
DllStructSetData($tMargs, 2, 0)
DllStructSetData($tMargs, 3, 0)
DllStructSetData($tMargs, 4, 0)
DllCall("dwmapi.dll", "int", "DwmExtendFrameIntoClientArea", "hwnd", $hParent, "ptr", DllStructGetPtr($tMargs))

Global $hChildMask = GUICreate("test", 182, 402, 1, 1, $WS_POPUP, $WS_EX_MDICHILD, $hParent)
GUISetBkColor(0x202025, $hChildMask)
GUISetState(@SW_SHOW, $hChildMask)
WinSetTrans($hChildMask, "", 200)
;~ $hChildMask is here temporarily to show that I also need to add a color to the blurred area otherwise under solid white color nothing will be visible. I'll do this with GDI
;~ You can remove this GUI for testing

Global $hChild = GUICreate("test", 182, 402, 1, 1, $WS_POPUP, $WS_EX_MDICHILD, $hParent) ; <------ This window should be at the bottom of Z order
GUISetBkColor(0x000000, $hChild)
GUISetState(@SW_SHOW, $hChild)

Local $tStruct = DllStructCreate("int AccentState; int AccentFlags; int GradientColor; int AnimationId")
Local $tStructData = DllStructCreate("dword Attribute; ptr DataBuffer; ulong Size")
$tStruct.AccentState = 3
$tStructData.Attribute = 19
$tStructData.DataBuffer = DllStructGetPtr($tStruct)
$tStructData.Size = DllStructGetSize($tStruct)
DllCall("user32.dll", "bool", "SetWindowCompositionAttribute", "hwnd", $hChild, "ptr", DllStructGetPtr($tStructData))

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $idButton
            ExitLoop
    EndSwitch
WEnd

Desired result:

Spoiler

image.png.41625cb8c33d78b7936662d3aeef5168.png

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...