Jump to content

Recommended Posts

Posted (edited)

Hi guys, check it out this:

#include <GuiConstants.au3>
#include <WindowsConstants.au3>

$Main_GUI = GUICreate("Main", 500, 500)
GUISetState(@SW_SHOW, $Main_GUI)

$Child_GUI = GUICreate("Child", 200, 100, 10, 50)
GUISetState(@SW_SHOW, $Child_GUI)

DllCall("user32.dll", "int", "SetParent", "hwnd", $Child_GUI, "hwnd", $Main_GUI)

While 1
Switch GUIGetMsg()
     Case $GUI_EVENT_CLOSE
         Exit
EndSwitch
WEnd

I want to do the exact opposite, i'd like to have the Main_GUI always on focus and the $Child_GUI always without focus also if you click on it. And now you need to close the Child for close the Main

So, everything in this script is the opposite of the result i want to do.

Where i'm doing wrong?

Thanks for help ;)

Edited by johnmcloud
Posted

You can find a very good tutorial about how to work with two GUIs in the wiki.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

I have make the DllCall for set the child-parent, why i need to set it again in GuiCreate?

Also my Gui is in another Gui without using WinGetPos, my problem is the inverted close/focus of the child instead of the main.

Please provide an example script like mine if possible.

Thanks to all

Posted

#include <GuiConstants.au3>
#include <WindowsConstants.au3>
$Main_GUI = GUICreate("Main", 500, 500)
GUISetState(@SW_SHOW, $Main_GUI)
$Child_GUI = GUICreate("Child", 200, 100, 10, 50, -1, -1, $Main_GUI)
GUISetState(@SW_SHOW, $Child_GUI)

While 1
 $aMessage = GUIGetMsg(1)
 If $aMessage[0] = $GUI_EVENT_CLOSE And $aMessage[1] = $Main_GUI Then
  Exit
 EndIf
 If $aMessage[0] = $GUI_EVENT_CLOSE And $aMessage[1] = $Child_GUI Then
  GUIDelete ( $Child_GUI )
 EndIf
WEnd

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Posted (edited)

and the $Child_GUI always without focus also if you click on it

this is 100% ilogical, you cant have win with no focus even if you click on it and expect it to close when you click X on it!

they only thing you can do is disable that win so that he dont get any focus or input at all and close it with other win

(or i totaly did not understand the problem)

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Posted (edited)

#include <GuiConstants.au3>
#include <WindowsConstants.au3>
$Main_GUI = GUICreate("Main", 500, 500)
GUISetState(@SW_SHOW, $Main_GUI)
GuiSetState ( @SW_DISABLE, $Main_GUI )
$Child_GUI = GUICreate("Child", 200, 100, 10, 50, -1, -1, $Main_GUI)
GUISetState(@SW_SHOW, $Child_GUI)

While 1
$aMessage = GUIGetMsg(1)
If $aMessage[0] = $GUI_EVENT_CLOSE And $aMessage[1] = $Main_GUI Then
Exit
EndIf
If $aMessage[0] = $GUI_EVENT_CLOSE And $aMessage[1] = $Child_GUI Then
GUIDelete ( $Child_GUI )
GuiSetState ( @SW_ENABLE, $Main_GUI )
EndIf
WEnd

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Posted

@bogQ It's possible, i'm sure at 100%. The Main GUI is always focused also if you click-move on the child gui, and the child gui don't have focus, never, but you can move-click like a normal gui. If you move the Main Gui the child gui follow it, the child gui is inside the main gui and can't go outside, but can be minimized,maximized and closed. Close the main gui close also the child.

I don't know if i can post binary of other language, but i have see this with my eyes, i have here on my pc.

Make a gui like that can be really useful imho.

@jdelaney

I'll test it soon, now i afk but thanks.

Posted (edited)

something like this?

#include <GuiConstants.au3>
#include <WindowsConstants.au3>

$Main_GUI = GUICreate("Main", 500, 500)
GUISetState(@SW_SHOW, $Main_GUI)
$Child_GUI = GUICreate("Child", 200, 100, 10, 50, $WS_CHILD + $WS_CAPTION +$WS_SYSMENU, Default, $Main_GUI)
GUICtrlCreateButton('SecondguiButton', 0, 0)
GUISetState(@SW_SHOW, $Child_GUI)
While 1
Switch GUIGetMsg()
     Case $GUI_EVENT_CLOSE
         Exit
EndSwitch
WEnd

edit: if its something like that, than i still do think that you did switch the word "focus" for something else on your mind and added the wrong meaning to it.

No focus = no interaction. Blue line on top of win isnt applicable indicator.

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Posted (edited)

this one is pretty cool, you can minimize/maximize within the parent window:

#include <GuiConstants.au3>
#include <WindowsConstants.au3>
$Main_GUI = GUICreate("Main", 500, 500)
GUISetState(@SW_SHOW, $Main_GUI)
$Child_GUI = GUICreate("Child", 200, 100, 10, 50, bitor( $WS_OVERLAPPEDWINDOW,$WS_CHILD , $WS_CAPTION ,$WS_SYSMENU),-1 , $Main_GUI)
GUICtrlCreateButton('SecondguiButton', 0, 0)
GUISetState(@SW_SHOW, $Child_GUI)
While 1
Switch GUIGetMsg()
     Case $GUI_EVENT_CLOSE
         Exit
EndSwitch
WEnd

also, for the closing issue, you need to use the while loop like I posted above

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Posted

bogQ

based on your

#include <GuiConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

$Main_GUI = GUICreate("Main", 500, 500)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetState(@SW_SHOW, $Main_GUI)

$Child_GUI = GUICreate("Child", 200, 100, 10, 50, BitOr($WS_CHILD, $WS_OVERLAPPEDWINDOW), Default, $Main_GUI)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUICtrlCreateButton('SecondguiButton', 0, 0)
GUISetState(@SW_SHOW, $Child_GUI)

While 1
    Sleep(1000)
WEnd

Func _Exit()
    Switch @GUI_WinHandle
        Case $Main_GUI
            Exit
        Case $Child_GUI
            GUIDelete($Child_GUI)
    EndSwitch
EndFunc

another option

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

Opt("GUIOnEventMode", 1)

$Main_GUI = GUICreate("Main", 500, 500, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetState()

$Child_GUI = GUICreate("Child", 200, 100, 10, 50, $GUI_SS_DEFAULT_GUI, $WS_EX_MDICHILD, $Main_GUI)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$iButton = GUICtrlCreateButton('Start', 10, 10, 120, 22)
GUISetState(@SW_SHOW, $Child_GUI)

WinActivate($Main_GUI)
GUISwitch($Main_GUI) 

While 1
    Sleep(1000)
WEnd

Func _Exit()
    Switch @GUI_WinHandle
        Case $Main_GUI
            Exit
        Case $Child_GUI
            GUIDelete($Child_GUI)
    EndSwitch
EndFunc
Posted (edited)

Nice example, thanks :)

I'm trying, using the same method, to make a floating GUI inside another software ( like Photoshop panel for make an idea )

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

HotKeySet("{ESC}", "Close")

$PID = Run(@WindowsDir & 'notepad.exe')
$PARENT = _GetHwndFromPID($PID)
$CHILD = GUICreate("GUI Inside Notepad", 400, 400, 0, 0, $WS_OVERLAPPEDWINDOW, $WS_EX_COMPOSITED)

_WinAPI_SetParent($CHILD, $PARENT)

GUISetState(@SW_SHOW)

While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   ExitLoop
 EndSwitch
 If Not ProcessExists("notepad.exe") Then
  Exit
 EndIf
 Sleep(100)
WEnd

Func _GetHwndFromPID($PID)
 $hWnd = 0
 $stPID = DllStructCreate("int")
 Do
  $winlist2 = WinList()
  For $i = 1 To $winlist2[0][0]
   If $winlist2[$i][0] <> "" Then
    DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $winlist2[$i][1], "ptr", DllStructGetPtr($stPID))
    If DllStructGetData($stPID, 1) = $PID Then
     $hWnd = $winlist2[$i][1]
     ExitLoop
    EndIf
   EndIf
  Next
  Sleep(100)
 Until $hWnd <> 0
 Return $hWnd
EndFunc   ;==>_GetHwndFromPID

Func Close()
 Exit
EndFunc   ;==>Close

Main problems are:

1) Move autoit GUI is little flickering, don't know how to update it

2) If i click on Notepad the gui disappear

For the second point:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms633541(v=vs.85).aspx

I don't understand the Remarks part about WS_POPUP style and the WS_CHILD, this part:

Therefore, if [i]hWndNewParent[/i] is [b]NULL[/b], you should also clear the [b]WS_CHILD[/b] bit and set the [b]WS_POPUP[/b] style after calling [b]SetParent[/b]

Thanks for any help :)

EDIT: I think this post can be useful:

Edited by johnmcloud
Posted

I really don't understand the problem:

#include <WindowsConstants.au3>
#include <Constants.au3>
#include <WinAPI.au3>

$PARENT = GUICreate("Parent", 400, 300, 100, 100)
GUISetState(@SW_SHOW, $PARENT)
$CHILD = GUICreate("Child", 200, 100, 200, 200)
GUISetState(@SW_SHOW, $CHILD)

DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $CHILD, "int", -16, "long", $WS_POPUP)
DllCall("user32.dll", "int", "SetParent", "hwnd", $CHILD, "hwnd", $PARENT)
DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $CHILD, "int", -16, "long", $WS_CHILD)
;~ _WinAPI_SetWindowLong($CHILD, $GWL_STYLE, $WS_POPUP)
;~ _WinAPI_SetParent($CHILD, $PARENT)
;~ _WinAPI_SetWindowLong($CHILD, $GWL_STYLE, $WS_CHILD)

While 1
 Sleep(100)
WEnd

I have do what the MSDN say, but i can't move the child gui... :mad:

Try it with DllCall and WinApi, same result...

Need a help here :D

Posted (edited)

for notepad problem the answer is probably betwean lines...

The new parent window and the child window must belong to the same application.

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Posted

Do you mean the flickering or the gui disappear?

For the flickering, i rebember to see a WinApi function for redraw the GUI, the problem is remember the name and how to apply.

For the gui disapper, it's only a child not correct configuration, because the child remove the focus for the parent ( the msdn say i can create a child gui and when i click on it, it don't take the focus from the main gui. I have post an example script with 2 ie in one autoit gui, when you click on ie the main gui don't lose focus )

Anyway, not work also with 2 autoit gui, but i don't understand the problem...

Posted (edited)

I have found a solution for the flickering problem for the autoit gui on notepad, add this 2 Style to the child autoit gui:

$GUI = GUICreate("GUI Inside Notepad", 400, 400, 0, 0, $WS_OVERLAPPEDWINDOW, $WS_EX_COMPOSITED)

1 problem solved, 1 to go ( p.s. child correct configuration, avoid parent from losing focus for 2 autoit GUI )

I have never seen a GUI like this ( except for the example posted above #13 ) so i think this was an intresting stuff...but i'm wrong :D

Where are all MPVs and expert of this forum, on vacation? Lucky they :D

EDIT: Update post #13 script with no flickering problem

Edited by johnmcloud

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...