Jump to content
TheAutomator

$WS_EX_MDICHILD bug

Recommended Posts

TheAutomator

Hi,

can someone tell me why the child-window disappears right after i run this example script?

i'm using windows7 64 bit..

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


Example()


Func Example()
    Local $sFilePath = "..\GUI\logo4.gif"


    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example", 400, 100)
    GUICtrlCreatePic("..\GUI\msoobe.jpg", 0, 0, 400, 100)


    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)


    Local $hChild = GUICreate("", 169, 68, 20, 20, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hGUI)


    ; Create a picture control with a transparent image.
    GUICtrlCreatePic($sFilePath, 0, 0, 169, 68)


    ; Display the child GUI.
    GUISetState(@SW_SHOW)


    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop


        EndSwitch
    WEnd


    ; Delete the previous GUIs and all controls.
    GUIDelete($hGUI)
    GUIDelete($hChild)
EndFunc   ;==>Example

Regards

TheAutomator.

Share this post


Link to post
Share on other sites
BrewManNH

I don't know for certain, but the help file says you can't use $WS_POPUP or $WS_EX_LAYERED on a child window.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
TheAutomator
BrewManNH,

Ok, i removed the $WS_EX_LAYERED but still no window inside the main gui...

Can i ask you something?

What i need is a gui with a child gui inside (mdi).

I don't know what your OS is but how would you code this?

The only thing that seems to work is this but you can't drag the windows inside the form around and they have no border:

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


$ParentForm = GUICreate("Example", 460, 260)
GUISetState(@SW_SHOW)


Global $ChildForm1 = GUICreate("", 460, 260, 0, 0, $WS_CHILD, Default, $ParentForm)
Global $GoTo_ChildForm2 = GUICtrlCreateButton("Next form", 320, 20, 120, 40)
GUISetState(@SW_SHOW)


Global $ChildForm2 = GUICreate("", 460, 260, 0, 0, $WS_CHILD, $WS_EX_CONTROLPARENT, $ParentForm)
Global $Label = GUICtrlCreateLabel("this is form 2", 20, 80, 414, 28)
GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif")
GUISetState(@SW_HIDE)


While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GoTo_ChildForm2
            GUISetState(@SW_HIDE, $ChildForm1)
            GUISetState(@SW_SHOW, $ChildForm2)
    EndSwitch
WEnd

regards

TheAutomator.

Share this post


Link to post
Share on other sites
Melba23

TheAutomator,

Is this something like what you are looking for? :huh:

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

Global Const $SC_DRAGMOVE = 0xF012

$ParentForm = GUICreate("Example", 460, 260)
GUISetBkColor(0xFF0000)
GUISetState(@SW_SHOW)


Global $ChildForm1 = GUICreate("", 460, 260, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $ParentForm)
GUISetBkColor(0x00FF00)
Global $GoTo_ChildForm2 = GUICtrlCreateButton("Next form", 320, 20, 120, 40)
GUISetState(@SW_SHOW)


Global $ChildForm2 = GUICreate("", 460, 260, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $ParentForm)
GUISetBkColor(0x0000FF)
Global $Label = GUICtrlCreateLabel("this is form 2", 20, 80, 414, 28)
GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif")
GUISetState(@SW_HIDE)


While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GoTo_ChildForm2
            GUISetState(@SW_HIDE, $ChildForm1)
            GUISetState(@SW_SHOW, $ChildForm2)
        Case $GUI_EVENT_PRIMARYDOWN
            _SendMessage(WinGetHandle("[ACTIVE]"), $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
    EndSwitch
WEnd
M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
TheAutomator

TheAutomator,

Is this something like what you are looking for? :huh:

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

Global Const $SC_DRAGMOVE = 0xF012

$ParentForm = GUICreate("Example", 460, 260)
GUISetBkColor(0xFF0000)
GUISetState(@SW_SHOW)


Global $ChildForm1 = GUICreate("", 460, 260, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $ParentForm)
GUISetBkColor(0x00FF00)
Global $GoTo_ChildForm2 = GUICtrlCreateButton("Next form", 320, 20, 120, 40)
GUISetState(@SW_SHOW)


Global $ChildForm2 = GUICreate("", 460, 260, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $ParentForm)
GUISetBkColor(0x0000FF)
Global $Label = GUICtrlCreateLabel("this is form 2", 20, 80, 414, 28)
GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif")
GUISetState(@SW_HIDE)


While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GoTo_ChildForm2
            GUISetState(@SW_HIDE, $ChildForm1)
            GUISetState(@SW_SHOW, $ChildForm2)
        Case $GUI_EVENT_PRIMARYDOWN
            _SendMessage(WinGetHandle("[ACTIVE]"), $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
    EndSwitch
WEnd
M23

 

 

Hi again Melba23  :)

This is what i'm trying to do but it won't work:

'>

or this:

'>

Regards

TheAutomator.

Edited by TheAutomator

Share this post


Link to post
Share on other sites
SmOke_N

I wrote this 7+ years ago, it doesn't use the _WinAPI* functions (which is easy enough to implement), but is this what you're looking to do?

Because I believe class names have changed for the explorer windows, try this revised example to see if it's the effect you want.

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

Global $ghGUI = GUICreate("MyExplorer", 1200, 500, -1, -1, BitOr($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_CLIPCHILDREN))
Global $goShell1 = _createNewExplorerWindow()
Global $goShell2 = _createNewExplorerWindow()
Global $ghExp1 = _WinEmbedToGUI(HWnd($goShell1.hwnd), $ghGUI, 600, 0, 600, 500)
Global $ghExp2 = _WinEmbedToGUI(HWnd($goShell2.hwnd), $ghGUI, 0, 0, 600, 500)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUISetState(@SW_HIDE, $ghGUI)
            WinClose($ghExp1)
            WinClose($ghExp2)
            Exit
    EndSwitch
WEnd

Func _createNewExplorerWindow()

    Local $oShell = ObjCreate("Shell.Application")
    Local $oWin1 = $oShell.windows(), $oWin2
    Local $nCount = $oWin1.count()

    $oShell.Explore("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")
    Do
        Sleep(50)
        $oWin2 = $oShell.windows()
    Until $nCount <> $oWin2.count()

    Return $oWin2($oWin2.count() - 1)
EndFunc

Func _WinEmbedToGUI($hWnd, $hGUI, $nLeftGUI, $nTopGUI, $nRightGUI, $nBottomGUI, $nStyle = -2, $nExStyle = -2)
    Local $nExStyleEx = DllCall("user32.dll", "int", "GetWindowLong", "hwnd", $hWnd, "int", -20)
    If IsArray($nExStyleEx) = 0 Then Return SetError(1, 0, 0)
    DllCall("user32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", -20, "int", BitOr($nExStyleEx[0], 0x00000040));WS_EX_MDICHILD
    DllCall("user32.dll", "int", "SetParent", "hwnd", $hWnd, "hwnd", $hGUI)
    WinSetState($hWnd, '', @SW_SHOW)
    WinMove($hWnd, "", $nLeftGUI, $nTopGUI, $nRightGUI, $nBottomGUI)
    If $nStyle = -2 And $nExStyle = -2 Then Return $hWnd
    Local $GWL_STYLE = -16, $GWL_EXSTYLE = -20
    Local $SWP_NOMOVE = 0x2, $SWP_NOSIZE = 0x1
    Local $SWP_SHOWWINDOW = 0x40, $SWP_NOZORDER = 0x4
    Local $iFlags = BitOR($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER)
    If $nStyle = -2 Then $nStyle = $WS_MINIMIZEBOX + $WS_CAPTION + $WS_POPUP + $WS_SYSMENU
    If $nExStyle = -2 Then $nExStyle = $nExStyleEx[0]
    DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "int", $nStyle)
    DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_EXSTYLE, "int", $nExStyle)
    DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hWnd, "hwnd", 0, "int", 0, "int", 0, _
            "int", 0, "int", 0, "int", $iFlags)
    Return $hWnd
EndFunc

Edit:

With _WinAPI function rather than straight dllcalls (I removed the WinSetState() as well, no idea why I had that there though.):

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

Global $ghGUI = GUICreate("MyExplorer", 1200, 500, -1, -1, BitOr($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_CLIPCHILDREN))
Global $goShell1 = _createNewExplorerWindow()
Global $goShell2 = _createNewExplorerWindow()
Global $ghExp1 = _Win_EmbedToHwnd(HWnd($goShell1.hwnd), $ghGUI, 600, 0, 600, 500)
Global $ghExp2 = _Win_EmbedToHwnd(HWnd($goShell2.hwnd), $ghGUI, 0, 0, 600, 500)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUISetState(@SW_HIDE, $ghGUI)
            WinClose($ghExp1)
            WinClose($ghExp2)
            Exit
    EndSwitch
WEnd

Func _createNewExplorerWindow()

    Local $oShell = ObjCreate("Shell.Application")
    Local $oWin1 = $oShell.windows(), $oWin2
    Local $nCount = $oWin1.count()

    $oShell.Explore("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")
    Do
        Sleep(10)
        $oWin2 = $oShell.windows()
    Until $nCount <> $oWin2.count()

    Return $oWin2($oWin2.count() - 1)
EndFunc

Func _Win_EmbedToHwnd($hChild, $hParent, $nLeftParent, $nTopParent, $nRightParent, _
        $nBottomParent, $iStyle = Default, $iExStyle = Default)

    Local Const $GWL_STYLE = -16, $GWL_EXSTYLE = -20
    Local Const $SWP_NOSIZE = 0x01, $SWP_NOMOVE = 0x02
    Local Const $SWP_NOZORDER = 0x04, $SWP_SHOWWINDOW = 0x40
    Local Const $WS_EX_MDICHILD = 0x00000040

    Local $iLongEx = _WinAPI_GetWindowLong($hChild, $GWL_EXSTYLE)
    If @error Then
        Return SetError(1, 0, 0)
    EndIf

    $iStyle = ((IsKeyword($iStyle) Or $iStyle < 0) ? _
        BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU) : $iStyle)
    $iExStyle = ((IsKeyword($iExStyle) Or $iExStyle < 0) ? $iLongEx : $iExStyle)

    Local Const $iFlags = BitOR($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER)

    ; set to mdi child
    _WinAPI_SetWindowLong($hChild, $GWL_EXSTYLE, BitOr($iLongEx, $WS_EX_MDICHILD))
    _WinAPI_SetParent($hChild, $hParent)
    WinMove($hChild, "", $nLeftParent, $nTopParent, $nRightParent, $nBottomParent)

    _WinAPI_SetWindowLong($hChild, $GWL_STYLE, $iStyle)
    _WinAPI_SetWindowLong($hChild, $GWL_EXSTYLE, $iExStyle)
    _WinAPI_SetWindowPos($hChild, 0, 0, 0, 0, 0, $iFlags)
    _WinAPI_SetFocus($hParent)

    Return $hChild
EndFunc
Edited by SmOke_N
  • Like 1

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Melba23

TheAutomator,

If that is what you need then use the API like this: :)

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

Global $hMain, $ahChild[1][2] = [[0, 0]], $SC_MOVE = 0xF010
$hMain = GUICreate("Parent Window", 633, 447, 192, 200)
GUICtrlCreateLabel("", 0, 0, 0, 0) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$mMain = GUICtrlCreateMenu("New")
$mChild = GUICtrlCreateMenuItem("Child", $mMain)
GUISetState(@SW_SHOW)

; Prevent maximised children being moved
GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND")

While 1
    ; Use advanced GUIGetMsg to distinguish between windows
    $aMsg = GUIGetMsg(1)
    Switch $aMsg[1]
        ; It is the parent
        Case $hMain
            ; Now check the message
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $mChild
                    CreateChild()
            EndSwitch
        ; Must be a child
        Case Else
            ; But which one?
            For $i = 1 To $ahChild[0][0]
                If $aMsg[1] = $ahChild[$i][0] Then
                    ; Check the message
                    Switch $aMsg[0]
                        Case $GUI_EVENT_CLOSE
                            GUIDelete($ahChild[$i][0])
                        Case $GUI_EVENT_MAXIMIZE
                            ; Set the Maximised flag
                            $ahChild[$i][1] = True
                        Case $GUI_EVENT_MINIMIZE
                            ; Clear the Maximised flag
                            $ahChild[$i][1] = False
                        Case $GUI_EVENT_RESTORE
                            ; Clear the Maximised flag
                            $ahChild[$i][1] = False
                    EndSwitch
                EndIf
            Next
    EndSwitch
WEnd

Func CreateChild()
    $hNew_Child = GUICreate("Child " & $ahChild[0][0] + 1, 300, 300, 10, 0, BitOR($GUI_SS_DEFAULT_GUI , $WS_MAXIMIZEBOX))
    _WinAPI_SetParent($hNew_Child, $hMain)
    Add($ahChild, $hNew_Child)
    GUISetState()
EndFunc   ;==>CreateChild

Func Add(ByRef $aArray, $hHandle)
    ; Increase the number of children
    $aArray[0][0] += 1
    ; Resize the array
    ReDim $aArray[$aArray[0][0] + 1][2]
    ; Add the child details
    $aArray[$aArray[0][0]][0] = $hHandle
    $aArray[$aArray[0][1]][1] = False
EndFunc   ;==>Add

Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)

    For $i = 1 To $ahChild[0][0]
        ; Does the message come from a child?
        If $hWnd = $ahChild[$i][0] Then
            ; Is the child maximised?
            If $ahChild[$i][1] Then
                ;Is it a MOVE mesage?
                If BitAND($wParam, 0xFFF0) = $SC_MOVE Then Return False
                ExitLoop
            EndIf
        EndIf
    Next

    Return $GUI_RUNDEFMSG
EndFunc   ;==>On_WM_SYSCOMMAND
Obviously a bit more than you wanted, but you can see that the children are limited to to the main GUI client area. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Yashied

Share this post


Link to post
Share on other sites
TheAutomator

TheAutomator,

If that is what you need then use the API like this: :)

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

Global $hMain, $ahChild[1][2] = [[0, 0]], $SC_MOVE = 0xF010
$hMain = GUICreate("Parent Window", 633, 447, 192, 200)
GUICtrlCreateLabel("", 0, 0, 0, 0) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$mMain = GUICtrlCreateMenu("New")
$mChild = GUICtrlCreateMenuItem("Child", $mMain)
GUISetState(@SW_SHOW)

; Prevent maximised children being moved
GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND")

While 1
    ; Use advanced GUIGetMsg to distinguish between windows
    $aMsg = GUIGetMsg(1)
    Switch $aMsg[1]
        ; It is the parent
        Case $hMain
            ; Now check the message
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $mChild
                    CreateChild()
            EndSwitch
        ; Must be a child
        Case Else
            ; But which one?
            For $i = 1 To $ahChild[0][0]
                If $aMsg[1] = $ahChild[$i][0] Then
                    ; Check the message
                    Switch $aMsg[0]
                        Case $GUI_EVENT_CLOSE
                            GUIDelete($ahChild[$i][0])
                        Case $GUI_EVENT_MAXIMIZE
                            ; Set the Maximised flag
                            $ahChild[$i][1] = True
                        Case $GUI_EVENT_MINIMIZE
                            ; Clear the Maximised flag
                            $ahChild[$i][1] = False
                        Case $GUI_EVENT_RESTORE
                            ; Clear the Maximised flag
                            $ahChild[$i][1] = False
                    EndSwitch
                EndIf
            Next
    EndSwitch
WEnd

Func CreateChild()
    $hNew_Child = GUICreate("Child " & $ahChild[0][0] + 1, 300, 300, 10, 0, BitOR($GUI_SS_DEFAULT_GUI , $WS_MAXIMIZEBOX))
    _WinAPI_SetParent($hNew_Child, $hMain)
    Add($ahChild, $hNew_Child)
    GUISetState()
EndFunc   ;==>CreateChild

Func Add(ByRef $aArray, $hHandle)
    ; Increase the number of children
    $aArray[0][0] += 1
    ; Resize the array
    ReDim $aArray[$aArray[0][0] + 1][2]
    ; Add the child details
    $aArray[$aArray[0][0]][0] = $hHandle
    $aArray[$aArray[0][1]][1] = False
EndFunc   ;==>Add

Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)

    For $i = 1 To $ahChild[0][0]
        ; Does the message come from a child?
        If $hWnd = $ahChild[$i][0] Then
            ; Is the child maximised?
            If $ahChild[$i][1] Then
                ;Is it a MOVE mesage?
                If BitAND($wParam, 0xFFF0) = $SC_MOVE Then Return False
                ExitLoop
            EndIf
        EndIf
    Next

    Return $GUI_RUNDEFMSG
EndFunc   ;==>On_WM_SYSCOMMAND
Obviously a bit more than you wanted, but you can see that the children are limited to to the main GUI client area. ;)

M23

 

 

That is EXACTLY what i was looking for  :thumbsup:

Also thanks to SmOke_N for his example :)

At first I thought it could be done with a simple child window and some variable like $WS_EMBEDDED_CHILD or something so I searched the web but

couldn't find any working example.

_WinAPI_SetParent seems to be the solution, thanks  ;)

TheAutomator.

Share this post


Link to post
Share on other sites
Melba23

TheAutomator,

Glad we finally got there. :)

M23

P.S. When you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unnecessarily. ;)


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Melba23

TheAutomator,

using child windows this way is extremely buggy

In what way? :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
TheAutomator
Melba23,

 

Well for example, if the parent window has a background image you can't see the child windows anymore until you hover over the maximize-button.

The child windows are not repainted the right way I guess and if you drag them around you get this type of behavior:

http://faildesk.net/wp-content/uploads/2012/10/Favorite-XP-Feature.jpg

also every other control in that same parent window is "glitch painted" on the child windows...

Share this post


Link to post
Share on other sites
Melba23

TheAutomator,

If you are using a background image, add the $WS_CLIPCHILDREN style to the parent: :)

$hMain = GUICreate("Parent Window", 633, 447, 192, 200, BitOr($GUI_SS_DEFAULT_GUI ,$WS_CLIPCHILDREN))
M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
TheAutomator

Melba23,

Now the controls on the parent gui are invisible  :huh:, also the child windows are still buggy...

Never mind M23, i don't want to waste your time on this  :mellow:

I can always figure out how to mimic this child window behavior some other way if this stays a pain in the ***

Regards

TheAutomator.

Edited by TheAutomator

Share this post


Link to post
Share on other sites
Melba23

The Automator,

Disable the background picture control - then the controls become visible (just as the Help file tells you). ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
TheAutomator

Disable the background picture control - then the controls become visible (just as the Help file tells you). ;)

 

That was the first thing i did  :graduated:

so that's not the problem..

Edited by TheAutomator

Share this post


Link to post
Share on other sites
Melba23

TheAutomator,

It works when I try it - please post the code you are using so we can take a look. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
TheAutomator

Ok, press the "new" button and make sure you put a jpg image in the same folder of the script called "test.jpg".

$WS_CLIPCHILDREN seems to help a little bit, try to maximize the new child window and then click the restore button...

#include <EditConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinApi.au3>

$SCREEN = GUICreate('TEST FORM 1', 600, 400, -1, -1, BitOr($GUI_SS_DEFAULT_GUI ,$WS_CLIPCHILDREN))
    GUISetBkColor(0x000000)

$IMAGE = GUICtrlCreatePic('bliss.jpg', 0, 0, 600, 370)
    GUICtrlSetState(-1, $GUI_DISABLE)

$NEW = GUICtrlCreateButton('NEW', 0, 370, 60, 30)
    GUICtrlSetCursor(-1, 0)

$LST = GUICtrlCreateList('NEW FORM', 0, 190, 120, 200, $WS_BORDER)
    GUICtrlSetData(-1, 'EXIT')
    GUICtrlSetFont(-1, 8, 400, 0, 'System')
    GUICtrlSetColor(-1, 0x00FF00)
    GUICtrlSetBkColor(-1, 0x000000)
    GUICtrlSetState(-1, $GUI_HIDE)

$INP = GUICtrlCreateInput('TESTING...', 460, 372, 100, 28, BitOR($ES_CENTER, $ES_UPPERCASE, $ES_READONLY))
    GUICtrlSetFont(-1, 12, 400, 0, 'MS Sans Serif')
    GUICtrlSetColor(-1, 0x00FF00)
    GUICtrlSetBkColor(-1, 0x000000)
    GUICtrlSetCursor (-1, 2)

GUISetState(@SW_SHOW)

While True
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

        Case $NEW
            If BitAND(GUICtrlGetState($LST), $GUI_HIDE) = $GUI_HIDE Then
                GUICtrlSetState($LST, $GUI_SHOW)
            Else
                GUICtrlSetState($LST, $GUI_HIDE)
            EndIf

        Case $LST
            Switch GUICtrlRead($LST)
                Case 'EXIT'
                    Exit

                Case 'NEW FORM'
                    $hNew_Child = GUICreate("Child", 300, 300, 10, 0, BitOR($GUI_SS_DEFAULT_GUI , $WS_MAXIMIZEBOX))
                    _WinAPI_SetParent($hNew_Child, $screen)
                    GUISetState()
            EndSwitch

    EndSwitch
WEnd

Regards

TheAutomator

Share this post


Link to post
Share on other sites
Melba23

TheAutomator,

Why are you leaving the "NEW" GUI open once something has been selected? Just hide it before you create the child and there is no problem - at least when I run the script. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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

  • Similar Content

    • Emmhor1
      By Emmhor1
      Hi All,

      MAIN QUESTION:
      Is it possible to Call specific function within a GUI

      So I have a script with multiple functions although I don't want to use every function every time.
      My Idea is to create a simple GUI which allows me to select what functions I want to use then run the funtions by clicking a button.
      I have already made a GUI which allows me to select specific .exe's I would like to run after selection it runs the .exe one by one.
      This script is on my work laptops and cannot access it right now.
       
      Who can help me with this?
      GUIcreate
      Func1 
      Func2
      Func3
      Then have a boxes which allows me to select the specif Func.(I used GUIChecked and Unchecked in my other script)
      Then a button which executes/calls the selected functions
    • Blois
      By Blois
      Hi Guis,
       
      I need to create keyboard shortcut to navigate the tabs and activate them, but I could not use the code below:
      #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiTab.au3> #include <GUIConstantsEx.au3> HotKeySet("^{TAB}", "_TabRight") HotKeySet("^+{TAB}", "_TabLeft") $gui = GUICreate("test",450, 300) $Tab1 = GUICtrlCreateTab(20, 24, 425, 201) $TabSheet1 = GUICtrlCreateTabItem("Tabsheet 1") $lbContagemGrupos2 = GUICtrlCreateLabel("aaaa", 50, 50) GUICtrlSetColor(-1, 0x0000FF) GUICtrlCreateTabItem("") $TabSheet2 = GUICtrlCreateTabItem(" ") $TabSheet3 = GUICtrlCreateTabItem(" ") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _TabRight() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos + 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Func _TabLeft() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos - 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Exit  
      can you help me?
    • Pricehacker
      By Pricehacker
      Hello again!
      I have tried searching for quite some time now but couldn´t find a single working way to change the class of your GUI that doesn´t include changing it manually after its compilation.
      First or "AutoIt v3 GUI" is a pretty boring name tbh and i would like to spice it up a bit, also, and more importantly, I would like to identify my windows by something other than its title as it will change depending on some factors and im using two different programs independently as multi threading isn't supported.
      Any help is appreciated! Thank you!
    • xtcislove
      By xtcislove
      Hello, 
      i have a Problem with  _WinAPI_SetLayeredWindowAttributes, everything is working as excepted if u are on Windows 7.

      But if u are on Windows 10 the transparent background of a control is not clickable anymore. 

      Could someone help?

      Please see example below, put cmd.jpg into the same folder as Example.au3

      Please see trigger.jpg to see which sections are not clickable in Windows 10 (the red dots, the green dots are clickable) on Windows 7 the red ones and green ones are clickable.
       
      The same problem occurs if i use 
       
       
      Example.au3


    • WilliamasKumeliukas
      By WilliamasKumeliukas
      Hello everyones reading this post,
      I'm struggling at resizing properly my radio buttons to fit long text inside without affecting others radio buttons and also adjust position of them relative to the string.
      I tried with _StringSize UDF but I guess im too tired to figure out how to use it correctly..
      I also tried: _Control_SetWidth2Text I found on this forum, it work aslong im not maximizing GUI (radio text is gone when I maximize and maximize is a must)
       
      here is the code example, I hope someone can figure out (sorry if guictrlsetpos is not included in the example, I know thats probably the way to go but I wanted to make sure there is nothing better before use it)
      Thank you
       
      Br,
      ~WilliamasKumeliukas
       
      #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <Array.au3> #include <StringConstants.au3> #include <FileConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <EditConstants.au3> #include <GUIListBox.au3> #include <ButtonConstants.au3> #include <ProgressConstants.au3> #include <ColorConstants.au3> #include <AutoitConstants.au3> #include <Misc.au3> #include <WinAPIReg.au3> #include <WinAPI.au3> #Region Opt's Opt("GUIResizeMode", 802) #EndRegion Opt's Global $q = "INTRO LINE" & @CRLF & @CRLF & "description of everything until user press start." Global $file = @TempDir & "\test.p" destroy() Global $msg, $score = 0, $rate, $com, $total = 0, $cfile, $cq, $i = 0, $time = 0, $min = 0, $sec = 0, $hour = 0, $qf, $ii = 0 Main() Func Main() Global $iGUIInitSize = 550 #Region GUI Opt("GUICloseOnEsc", 1) Global $gui = GUICreate("example", 1124, 550,-1 ,-1, BitOR($WS_MAXIMIZEBOX , $WS_MINIMIZEBOX)) Global $gui_size = WinGetClientSize($gui) Global $iFontSize = Int(2 * (.25 + (8 * $gui_size[0] / $iGUIInitSize))) / 2 Global $options = GUICtrlCreateMenu("&Options") Global $guide = GUICtrlCreateMenuItem("Guide", $options) Global $restart = GUICtrlCreateMenuItem("Restart", $options) Global $about = GUICtrlCreateMenuItem("About", $options) Global $exit = GUICtrlCreateMenuItem("Exit", $options) Global $extra = GUICtrlCreateMenu("Extras") Global $creator = GUICtrlCreateMenu("CQB", $extra ) Global $new = GUICtrlCreateMenuItem("custom QP", $creator) Global $load = GUICtrlCreateMenuItem("CQ", $creator ) Global $timer = GUICtrlCreateLabel("", 752, 472, 294, 30, $WS_BORDER) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) GUICtrlSetFont(-1, $iFontSize) GUICtrlSetState($timer, $GUI_HIDE) Global $info = GUICtrlCreateLabel( $q, 200, 20, 700, 200, $SS_CENTER ) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) $fi = GUICtrlSetFont($info, $iFontSize) Global $a = GUICtrlCreateRadio("A)", 100, 210, $WS_EX_CLIENTEDGE) $fa = GUICtrlSetFont($a, 15) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) GUICtrlSetState($a, 16) Global $b = GUICtrlCreateRadio("B)", 100, 310 , $WS_EX_CLIENTEDGE) $fb = GUICtrlSetFont($b, 15) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) GUICtrlSetState($b, 16) Global $c = GUICtrlCreateRadio("C)", 750, 210 , $WS_EX_CLIENTEDGE) $fc = GUICtrlSetFont($c, 15) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) GUICtrlSetState($c, 16) Global $d = GUICtrlCreateRadio( "D) ", 750, 310, $WS_EX_CLIENTEDGE) $fd = GUICtrlSetFont($d, 15) GUICtrlSetResizing (-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) GUICtrlSetState($d, 16) Global $sign = GUICtrlCreateLabel( $file, 420, 480, -1, -1, BitOR ( $SS_CENTER, $WS_BORDER ) ) GUICtrlSetResizing ( -1, BitOR ( $GUI_DOCKHCENTER, $GUI_DOCKVCENTER ) ) GUICtrlSetFont($sign, 12) Global $yb = GUICtrlCreateRadio("True", 200, 420, 200, 50, $BS_PUSHLIKE) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER,$GUI_DOCKSIZE)) GUICtrlSetFont($yb, 15) GUICtrlSetState($yb, 32) Global $nb = GUICtrlCreateRadio("False", 700, 420, 200, 50, $BS_PUSHLIKE) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER, $GUI_DOCKSIZE)) GUICtrlSetFont($nb, 15) GUICtrlSetState($nb, 32) Global $start = GUICtrlCreateButton("Start", 20, 20, 100, 50, $SS_CENTER, $WS_EX_CLIENTEDGE) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER)) GUICtrlSetFont($start, 12) Global $valid = GUICtrlCreateButton("Confirm", 20, 20, 100, 50, $SS_CENTER, $WS_EX_CLIENTEDGE) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER)) GUICtrlSetFont($valid, 12) GUICtrlSetState($valid, 32) GUISetState(@SW_SHOW) #EndRegion GUI While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Switch MsgBox(4096 + 4, "Warning", "Are you sure to exit?") Case 6 AdlibUnRegister("timer") If Not $qf = "" Then FileClose($file) EndIf Exit Case 7 ContinueLoop EndSwitch Case $start ;AdlibRegister("timer") ;Global $qf = StringSplit(StringStripWS(FileRead($file), 6), @CRLF, 0) ;qloop($file) GUICtrlSetData($a, "A) This long string is an example as string that I want to fit in 4 radio buttons because sometimes it can be that long.") GUICtrlSetData($b, "B) This long string is an example as string that I want to fit in 4 radio buttons because sometimes it can be that long.") GUICtrlSetData($c, "C) This long string is an example as string that I want to fit in 4 radio buttons because sometimes it can be that long.") GUICtrlSetData($d, "D) This long string is an example as string that I want to fit in 4 radio buttons because sometimes it can be that long.") Case $restart MsgBox(4096, "Warning", 'Normally, your suposed to start something before restarting it.') ContinueLoop Case $new ;GUISetState(@SW_HIDE, $gui) ;_CustomNew() ContinueLoop Case $load ;_CustomLoad() Case $about ;_About() EndSwitch WEnd EndFunc ;Main() Func timer() If $time = 0 Then Global $time = TimerInit() Global $diff = TimerDiff($time) Global $sec = Int(Mod($diff / 1000, 60)) Global $min = Int(Mod($diff / 60000, 60)) Global $hour = Int($diff / 3600000) If $sec < 10 Then $sec = "0" & $sec If $min < 10 Then $min = "0" & $min If $hour < 10 Then $hour = "0" & $hour GUICtrlSetData($timer, "Temps: " & $hour & ":" & $min & ":" & $sec) EndFunc ;==>timer Func destroy() If FileExists($file) Then FileDelete($file) EndIf DirCreate(@TempDir & "\About") FileInstall("C:\test.txt", $file) EndFunc ;==>destroy  
×