IanN1990 Posted January 11, 2020 Posted January 11, 2020 (edited) Hi All, I am working on a new UI design to allow greater flexibility. Below is a my core concept but GUICtrlCreatePic causes it to fail and i am unsure why. expandcollapse popup#NoTrayIcon #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> Example1() Example2() Example3() ;Working - The second GUI is now within the first GUI and they are linked. Func Example1() $hMainGUI = GUICreate("Main Background - Example 1", 500, 500, 0, 0) GUISetBkColor(0x000000) GUISetState() $hGUIOverlay = GUICreate("Test 1", 500, 475, 0, 0) GUISetBkColor(0x0000F4) GUICtrlCreateButton("C:\Program Files (x86)\AutoIt3\Examples\GUI\mslogo.jpg", 50, 50, 255, 40) GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\mslogo.jpg", 50, 100, 255, 40) GUISetState() _WinAPI_SetParent($hGUIOverlay, $hMainGUI) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete($hGUIOverlay) GUIDelete($hMainGUI) EndFunc ;Working - The second GUI is now transparent ;GUICtrlCreatePic commented out. Func Example2() $hMainGUI = GUICreate("Main Background - Example 2", 500, 500, 0, 0) GUISetBkColor(0x000000) GUISetState() $hGUIOverlay = GUICreate("Test 2", 500, 500, 0, 0, -1, $WS_EX_LAYERED) GUISetBkColor(0x0000F4) GUICtrlCreateButton("C:\Program Files (x86)\AutoIt3\Examples\GUI\mslogo.jpg", 50, 50, 255, 40) ;GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\mslogo.jpg", 50, 100, 255, 40) _WinAPI_SetParent($hGUIOverlay, $hMainGUI) _WinAPI_SetLayeredWindowAttributes($hGUIOverlay, 0x0000F4) GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete($hGUIOverlay) GUIDelete($hMainGUI) EndFunc ;Failed - Same code as above but GUICtrlCreatePic is now uncommented. ;Now nothing is shown Func Example3() $hMainGUI = GUICreate("Main Background - Example 3", 500, 500, 0, 0) GUISetBkColor(0x000000) GUISetState() $hGUIOverlay = GUICreate("Test 3", 500, 500, 0, 0, -1, $WS_EX_LAYERED) GUISetBkColor(0x0000F4) GUICtrlCreateButton("C:\Program Files (x86)\AutoIt3\Examples\GUI\mslogo.jpg", 50, 50, 255, 40) GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\mslogo.jpg", 50, 100, 255, 40) _WinAPI_SetParent($hGUIOverlay, $hMainGUI) _WinAPI_SetLayeredWindowAttributes($hGUIOverlay, 0x0000F4) GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete($hGUIOverlay) GUIDelete($hMainGUI) EndFunc Does anyone have any idea why it is failing and / or how to correct it? **The code Example 1 & 2 will only work on Windows 10 and anything less does not support layering of child windows. Why i am going down this route 1. This design would allow me to have videos playing in $MainGUI while not impacting / blocking other GUI elements layered over it. 2. Would allow me to create self-contained designed GUIs to be shown / hidden easily while having transparency. 3. The reason i need it working with pictures instead of just buttons is because of the graphic options it provides. I tired a button with $BS_BMP but it had the same outcome. 4. The reason for _WinAPI_SetParent instead WS_EX_MDICHILD and Parent handle is because these are not truly "linked". If i did GUISetState(@SW_Hide, $MainGUI) or winsettrans($MainGUI, "", 125) then $hGUIOverlay is unaffected. Though i could run the command on $hGUIOverlay this is twice the handle management and slows down ading animations. For $i = 240 to 0 step -15 winsettrans($MainGUI, "", $i) Next vs For $i = 240 to 0 step -15 winsettrans($MainGUI, "", $i) winsettrans($hGUIOverlay, "", $i) Next Edited January 11, 2020 by IanN1990
IanN1990 Posted January 11, 2020 Author Posted January 11, 2020 (edited) Sods law after creating a large post i end up making some headway! Seems the child-window needs to be moved into frame to be displayed correctly #NoTrayIcon #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> Example4() Func Example4() $hMainGUI = GUICreate("Main Background - Example 4", 500, 500, 0, 0, -1) GUISetBkColor(0x000000) GUISetState() $hGUIOverlay = GUICreate("Test 4", 500, 500, 0, 0, -1, $WS_EX_LAYERED) GUISetBkColor(0x0000F4) GUICtrlCreateButton("C:\Program Files (x86)\AutoIt3\Examples\GUI\mslogo.jpg", 50, 50, 255, 40) GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\mslogo.jpg", 50, 100, 255, 40) _WinAPI_SetLayeredWindowAttributes($hGUIOverlay, 0x0000F4) GUISetState() _WinAPI_SetParent($hGUIOverlay, $hMainGUI) _WinAPI_MoveWindow($hGUIOverlay, 0, 0, 500, 500) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete($hGUIOverlay) GUIDelete($hMainGUI) EndFunc Edited January 11, 2020 by IanN1990
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