Jump to content

Why does setting child window to @SW_SHOW block the script?


Recommended Posts

If you run the script and click and hold down the left mouse button over the top label, the count in the label below increments.

If you check the checkbox to show a grey box and click again you still get the count incrementing.

If you check the checkbox to use a child window then there is no counting because the script is blocked untill the mouse is released.

Why is that and what is a better way to deal with it than the work-around?

#include <GUIConstantsEx.au3>
 #include <WindowsConstants.au3>
 #include <misc.au3>
 
 Const $WS_EX_COMPOSITED = 0x2000000
 
 $g1 = GUICreate("hold left mouse button down when over label 'something'", 300, 300,200,200,-1,$WS_EX_COMPOSITED)
;GUISetBkColor(0x777777)
 GUISetState()
 $chk1 = GUICtrlCreateCheckbox("show grey box", 10, 200, 100, 20)
 $chk2 = GUICtrlCreateCheckbox("use child window for grey box", 10, 230, 200, 20)
 $chk3 = GUICtrlCreateCheckbox("Fix with workaround",10,280,200,20)
 
 $lab = GUICtrlCreateLabel("click me", 20, 20, 100, 20)
 GUICtrlSetBkColor(-1, 0xffffff)
 $lab2 = GUICtrlCreateLabel("", 20, 50, 100, 20)
 GUICtrlSetBkColor(-1, 0xffffff)
 
 $cover = GUICreate("cover", 150, 120, 120, 20, $WS_CHILD, -1, $g1)
 GUISetBkColor(0x777777)
 GUISetState(@SW_HIDE)
 
 $cover2 = GUICreate("cover2", 150, 120, 120+203, 20+230, $WS_POPUP)
 GUISetBkColor(0x777777)
 GUISetState(@SW_HIDE)
 
 
 GUISwitch($g1)
 While 1
     $Msg = GUIGetMsg()
     If $Msg = -3 Then Exit
     If $Msg = $lab Then
         $w = 20
         If BitAND(GUICtrlRead($chk1), $GUI_CHECKED) = $GUI_CHECKED Then
             If BitAND(GUICtrlRead($chk2), $GUI_CHECKED) = $GUI_CHECKED Then
                 ConsoleWrite("show child" & @CRLF)
                  If BitAND(GUICtrlRead($chk3), $GUI_CHECKED) = $GUI_CHECKED Then MouseUp("left")
                 GUISetState(@SW_SHOW, $cover)
                  If BitAND(GUICtrlRead($chk3), $GUI_CHECKED) = $GUI_CHECKED Then MouseDown("Left")
                 ConsoleWrite("after show child" & @CRLF)
             Else
                 GUISetState(@SW_SHOW, $cover2)
             EndIf
             
             GUISwitch($g1)
         EndIf
         ConsoleWrite("got to line 50" & @CRLF)
         $tc = 1
         While _IsPressed(01)
             GUICtrlSetData($lab2, $tc)
             $tc += 1
         WEnd
         GUISetState(@SW_HIDE, $cover)
         GUISetState(@SW_HIDE, $cover2)
     EndIf
 
 WEnd;
Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

If you run the script and click and hold down the left mouse button over the top label, the count in the label below increments.

If you check the checkbox to show a grey box and click again you still get the count incrementing.

If you check the checkbox to use a child window then there is no counting because the script is blocked untill the mouse is released.

Why is that and what is a better way to deal with it than the work-around?

#include <GUIConstantsEx.au3>
  #include <WindowsConstants.au3>
  #include <misc.au3>
  
  Const $WS_EX_COMPOSITED = 0x2000000
  
  $g1 = GUICreate("hold left mouse button down when over label 'something'", 300, 300,200,200,-1,$WS_EX_COMPOSITED)
;GUISetBkColor(0x777777)
  GUISetState()
  $chk1 = GUICtrlCreateCheckbox("show grey box", 10, 200, 100, 20)
  $chk2 = GUICtrlCreateCheckbox("use child window for grey box", 10, 230, 200, 20)
  $chk3 = GUICtrlCreateCheckbox("Fix with workaround",10,280,200,20)
  
  $lab = GUICtrlCreateLabel("click me", 20, 20, 100, 20)
  GUICtrlSetBkColor(-1, 0xffffff)
  $lab2 = GUICtrlCreateLabel("", 20, 50, 100, 20)
  GUICtrlSetBkColor(-1, 0xffffff)
  
  $cover = GUICreate("cover", 150, 120, 120, 20, $WS_CHILD, -1, $g1)
  GUISetBkColor(0x777777)
  GUISetState(@SW_HIDE)
  
  $cover2 = GUICreate("cover2", 150, 120, 120+203, 20+230, $WS_POPUP)
  GUISetBkColor(0x777777)
  GUISetState(@SW_HIDE)
  
  
  GUISwitch($g1)
  While 1
      $Msg = GUIGetMsg()
      If $Msg = -3 Then Exit
      If $Msg = $lab Then
          $w = 20
          If BitAND(GUICtrlRead($chk1), $GUI_CHECKED) = $GUI_CHECKED Then
              If BitAND(GUICtrlRead($chk2), $GUI_CHECKED) = $GUI_CHECKED Then
                  ConsoleWrite("show child" & @CRLF)
                   If BitAND(GUICtrlRead($chk3), $GUI_CHECKED) = $GUI_CHECKED Then MouseUp("left")
                  GUISetState(@SW_SHOW, $cover)
                   If BitAND(GUICtrlRead($chk3), $GUI_CHECKED) = $GUI_CHECKED Then MouseDown("Left")
                  ConsoleWrite("after show child" & @CRLF)
              Else
                  GUISetState(@SW_SHOW, $cover2)
              EndIf
              
              GUISwitch($g1)
          EndIf
          ConsoleWrite("got to line 50" & @CRLF)
          $tc = 1
          While _IsPressed(01)
              GUICtrlSetData($lab2, $tc)
              $tc += 1
          WEnd
          GUISetState(@SW_HIDE, $cover)
          GUISetState(@SW_HIDE, $cover2)
      EndIf
  
  WEnd;
Any suggestions?
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

There's always event mode:

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

Const $WS_EX_COMPOSITED = 0x2000000

Opt("GuiOnEventMode", 1)

Global $gMain, $ChkGreyBox, $ChkChildGreyBox, $lab, $lab2, $gChild, $gPopup
Global $f_ShowGreyBox = False, $f_ShowChildGreyBox = False
Global $f_ChngShowGreyBox = False, $f_ChngShowChildGreyBox = False

$gMain = GUICreate("hold left mouse button down when over label 'something'", 300, 300, 200, 200, -1, $WS_EX_COMPOSITED)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
$ChkGreyBox = GUICtrlCreateCheckbox("show grey box", 10, 200, 150, 20)
$ChkChildGreyBox = GUICtrlCreateCheckbox("use child window for grey box", 10, 230, 250, 20)
$lab = GUICtrlCreateLabel("click me", 20, 20, 100, 20)
GUICtrlSetOnEvent(-1, "_ClickMe")
GUICtrlSetBkColor(-1, 0xffffff)
$lab2 = GUICtrlCreateLabel("", 20, 50, 100, 20)
GUICtrlSetBkColor(-1, 0xffffff)
GUISetState()

$gChild = GUICreate("gChild", 150, 120, 550, 200, $WS_CHILD, -1, $gMain)
GUISetBkColor(0x777777)
GUISetState(@SW_HIDE)

$gPopup = GUICreate("gPopup", 150, 120, 550, 250, $WS_POPUP)
GUISetBkColor(0x777777)
GUISetState(@SW_HIDE)

While 1
    $f_Change = False

    $f_ChngShowGreyBox = (BitAND(GUICtrlRead($ChkGreyBox), $GUI_CHECKED) = $GUI_CHECKED)
    If $f_ChngShowGreyBox <> $f_ShowGreyBox Then
        $f_Change = True
        $f_ShowGreyBox = $f_ChngShowGreyBox
        ConsoleWrite("Debug: $f_ShowGreyBox changed to: " & $f_ShowGreyBox & @CRLF)
    EndIf

    $f_ChngShowChildGreyBox = (BitAND(GUICtrlRead($ChkChildGreyBox), $GUI_CHECKED) = $GUI_CHECKED)
    If $f_ChngShowChildGreyBox <> $f_ShowChildGreyBox Then
        $f_Change = True
        $f_ShowChildGreyBox = $f_ChngShowChildGreyBox
        ConsoleWrite("Debug: $f_ShowChildGreyBox changed to: " & $f_ShowChildGreyBox & @CRLF)
    EndIf

    If $f_Change Then
        $f_Change = False
        If $f_ShowGreyBox Then
            If $f_ShowChildGreyBox Then
                ConsoleWrite("Debug: Show child grey box" & @LF)
                GUISetState(@SW_SHOW, $gChild)
                GUISetState(@SW_HIDE, $gPopup)
            Else
                ConsoleWrite("Debug: Show popup grey box" & @LF)
                GUISetState(@SW_HIDE, $gChild)
                GUISetState(@SW_SHOW, $gPopup)
            EndIf
        Else
            ConsoleWrite("Debug: No grey box" & @LF)
            GUISetState(@SW_HIDE, $gChild)
            GUISetState(@SW_HIDE, $gPopup)
        EndIf
    EndIf

    Sleep(10)
WEnd

Func _ClickMe()
    $tc = 0
    Do
        $tc += 1
        GUICtrlSetData($lab2, $tc)
    Until _IsPressed("01") = 0
EndFunc  ;==>_ClickMe

Func _Quit()
    Exit
EndFunc  ;==>_Quit

^_^

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

There's always event mode:

#include <GUIConstantsEx.au3>
 #include <WindowsConstants.au3>
 #include <misc.au3>
 
 Const $WS_EX_COMPOSITED = 0x2000000
 
 Opt("GuiOnEventMode", 1)
 
 Global $gMain, $ChkGreyBox, $ChkChildGreyBox, $lab, $lab2, $gChild, $gPopup
 Global $f_ShowGreyBox = False, $f_ShowChildGreyBox = False
 Global $f_ChngShowGreyBox = False, $f_ChngShowChildGreyBox = False
 
 $gMain = GUICreate("hold left mouse button down when over label 'something'", 300, 300, 200, 200, -1, $WS_EX_COMPOSITED)
 GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
 $ChkGreyBox = GUICtrlCreateCheckbox("show grey box", 10, 200, 150, 20)
 $ChkChildGreyBox = GUICtrlCreateCheckbox("use child window for grey box", 10, 230, 250, 20)
 $lab = GUICtrlCreateLabel("click me", 20, 20, 100, 20)
 GUICtrlSetOnEvent(-1, "_ClickMe")
 GUICtrlSetBkColor(-1, 0xffffff)
 $lab2 = GUICtrlCreateLabel("", 20, 50, 100, 20)
 GUICtrlSetBkColor(-1, 0xffffff)
 GUISetState()
 
 $gChild = GUICreate("gChild", 150, 120, 550, 200, $WS_CHILD, -1, $gMain)
 GUISetBkColor(0x777777)
 GUISetState(@SW_HIDE)
 
 $gPopup = GUICreate("gPopup", 150, 120, 550, 250, $WS_POPUP)
 GUISetBkColor(0x777777)
 GUISetState(@SW_HIDE)
 
 While 1
     $f_Change = False
 
     $f_ChngShowGreyBox = (BitAND(GUICtrlRead($ChkGreyBox), $GUI_CHECKED) = $GUI_CHECKED)
     If $f_ChngShowGreyBox <> $f_ShowGreyBox Then
         $f_Change = True
         $f_ShowGreyBox = $f_ChngShowGreyBox
         ConsoleWrite("Debug: $f_ShowGreyBox changed to: " & $f_ShowGreyBox & @CRLF)
     EndIf
 
     $f_ChngShowChildGreyBox = (BitAND(GUICtrlRead($ChkChildGreyBox), $GUI_CHECKED) = $GUI_CHECKED)
     If $f_ChngShowChildGreyBox <> $f_ShowChildGreyBox Then
         $f_Change = True
         $f_ShowChildGreyBox = $f_ChngShowChildGreyBox
         ConsoleWrite("Debug: $f_ShowChildGreyBox changed to: " & $f_ShowChildGreyBox & @CRLF)
     EndIf
 
     If $f_Change Then
         $f_Change = False
         If $f_ShowGreyBox Then
             If $f_ShowChildGreyBox Then
                 ConsoleWrite("Debug: Show child grey box" & @LF)
                 GUISetState(@SW_SHOW, $gChild)
                 GUISetState(@SW_HIDE, $gPopup)
             Else
                 ConsoleWrite("Debug: Show popup grey box" & @LF)
                 GUISetState(@SW_HIDE, $gChild)
                 GUISetState(@SW_SHOW, $gPopup)
             EndIf
         Else
             ConsoleWrite("Debug: No grey box" & @LF)
             GUISetState(@SW_HIDE, $gChild)
             GUISetState(@SW_HIDE, $gPopup)
         EndIf
     EndIf
 
     Sleep(10)
 WEnd
 
 Func _ClickMe()
     $tc = 0
     Do
         $tc += 1
         GUICtrlSetData($lab2, $tc)
     Until _IsPressed("01") = 0
 EndFunc ;==>_ClickMe
 
 Func _Quit()
     Exit
 EndFunc ;==>_Quit

^_^

Thanks for your time looking at that PsaltyDS, unfortunately you are wrong. The idea of my example is that the window is shown when you press the left cursor button, and while the button is pressed the count is incremented.

If you use OnEvent or not then as soon as you set the state of a child window to "SW_SHOW then the script freezes untill the button is released.

This mod to your reply demonstrates.

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

Const $WS_EX_COMPOSITED = 0x2000000

Opt("GuiOnEventMode", 1)

Global $gMain, $ChkGreyBox, $ChkChildGreyBox, $lab, $lab2, $gChild, $gPopup
Global $f_ShowGreyBox = False, $f_ShowChildGreyBox = False
Global $f_ChngShowGreyBox = False, $f_ChngShowChildGreyBox = False

$gMain = GUICreate("hold left mouse button down when over label 'something'", 300, 300, 200, 200, -1, $WS_EX_COMPOSITED)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
$ChkGreyBox = GUICtrlCreateCheckbox("show grey box", 10, 200, 150, 20)
$ChkChildGreyBox = GUICtrlCreateCheckbox("use child window for grey box", 10, 230, 250, 20)
$lab = GUICtrlCreateLabel("click me", 20, 20, 100, 20)
GUICtrlSetOnEvent(-1, "_ClickMe")
GUICtrlSetBkColor(-1, 0xffffff)
$lab2 = GUICtrlCreateLabel("", 20, 50, 100, 20)
GUICtrlSetBkColor(-1, 0xffffff)
GUISetState()

$gChild = GUICreate("gChild", 150, 120, 550, 200, $WS_CHILD, -1, $gMain)
GUISetBkColor(0x777777)
GUISetState(@SW_HIDE)

$gPopup = GUICreate("gPopup", 150, 120, 550, 250, $WS_POPUP)
GUISetBkColor(0x777777)
GUISetState(@SW_HIDE)

While 1
    $f_Change = False

    $f_ChngShowGreyBox = (BitAND(GUICtrlRead($ChkGreyBox), $GUI_CHECKED) = $GUI_CHECKED)
    If $f_ChngShowGreyBox <> $f_ShowGreyBox Then
        $f_Change = True
        $f_ShowGreyBox = $f_ChngShowGreyBox
        ConsoleWrite("Debug: $f_ShowGreyBox changed to: " & $f_ShowGreyBox & @CRLF)
    EndIf

    $f_ChngShowChildGreyBox = (BitAND(GUICtrlRead($ChkChildGreyBox), $GUI_CHECKED) = $GUI_CHECKED)
    If $f_ChngShowChildGreyBox <> $f_ShowChildGreyBox Then
        $f_Change = True
        $f_ShowChildGreyBox = $f_ChngShowChildGreyBox
        ConsoleWrite("Debug: $f_ShowChildGreyBox changed to: " & $f_ShowChildGreyBox & @CRLF)
    EndIf

    If $f_Change Then
        $f_Change = False
        If $f_ShowGreyBox Then
            If $f_ShowChildGreyBox Then
                ConsoleWrite("Debug: Show child grey box" & @LF)
               ;GUISetState(@SW_SHOW, $gChild)
              ; GUISetState(@SW_HIDE, $gPopup)
            Else
                ConsoleWrite("Debug: Show popup grey box" & @LF)
              ; GUISetState(@SW_HIDE, $gChild)
               ;GUISetState(@SW_SHOW, $gPopup)
            EndIf
        Else
            ConsoleWrite("Debug: No grey box" & @LF)
          ; GUISetState(@SW_HIDE, $gChild)
          ; GUISetState(@SW_HIDE, $gPopup)
        EndIf
    EndIf

    Sleep(10)
WEnd

Func _ClickMe()
    $tc = 0
    if $f_ShowChildGreyBox then GUISetState(@SW_SHOW, $gChild)
    ConsoleWrite("line 74 reached" & @CRLF)
    Do
        $tc += 1
        GUICtrlSetData($lab2, $tc)
    Until _IsPressed("01") = 0
    GUISetState(@SW_HIDE, $gChild)
    
EndFunc ;==>_ClickMe

Func _Quit()
    Exit
EndFunc ;==>_Quit

I assume it is because the cursor is norcapture by the child window, but I'm very weak on this and I would like top understand why it happens and how I should deal with it.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • Developers

Looks like AutoIt3 tries to activate the window when GUISetState(@SW_SHOW, $cover) is performed and is unable to activate it while the mouse is down.

Maybe JP can confirm?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thanks for your time looking at that PsaltyDS, unfortunately you are wrong. The idea of my example is that the window is shown when you press the left cursor button, and while the button is pressed the count is incremented.

If you use OnEvent or not then as soon as you set the state of a child window to "SW_SHOW then the script freezes untill the button is released.

This mod to your reply demonstrates.

I assume it is because the cursor is norcapture by the child window, but I'm very weak on this and I would like top understand why it happens and how I should deal with it.

Drat! I broke something cleaning it up to post. I had it working because I changed the positions of the GUIs so I could see them properly. Then I did Tidy and cleaned up some unused variables, and now the child GUI never shows at all, even if you never click on the label at all.

^_^

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Drat! I broke something cleaning it up to post. I had it working because I changed the positions of the GUIs so I could see them properly. Then I did Tidy and cleaned up some unused variables, and now the child GUI never shows at all, even if you never click on the label at all.

^_^

That's because you misplaced it. You meant something like this:

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

Const $WS_EX_COMPOSITED = 0x2000000

Opt("GuiOnEventMode", 1)

Global $gMain, $ChkGreyBox, $ChkChildGreyBox, $lab, $lab2, $gChild, $gPopup
Global $f_ShowGreyBox = False, $f_ShowChildGreyBox = False
Global $f_ChngShowGreyBox = False, $f_ChngShowChildGreyBox = False

$gMain = GUICreate("hold left mouse button down when over label 'something'", 300, 300, 200, 200, -1, $WS_EX_COMPOSITED)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
$ChkGreyBox = GUICtrlCreateCheckbox("show grey box", 10, 200, 150, 20)
$ChkChildGreyBox = GUICtrlCreateCheckbox("use child window for grey box", 10, 230, 250, 20)
$lab = GUICtrlCreateLabel("click me", 20, 20, 100, 20)
GUICtrlSetOnEvent(-1, "_ClickMe")
GUICtrlSetBkColor(-1, 0xffffff)
$lab2 = GUICtrlCreateLabel("", 20, 50, 100, 20)
GUICtrlSetBkColor(-1, 0xffffff)
GUISetState()

$gChild = GUICreate("gChild", 150, 120, 120, 20, $WS_CHILD, -1, $gMain)
GUISetBkColor(0x777777)
GUISetState(@SW_HIDE)

$gPopup = GUICreate("gPopup", 150, 120, 120 + 203, 20 + 230, $WS_POPUP, -1, $gMain)

GUISetBkColor(0x777777)
GUISetState(@SW_HIDE)

While 1
    $f_Change = False

    $f_ChngShowGreyBox = (BitAND(GUICtrlRead($ChkGreyBox), $GUI_CHECKED) = $GUI_CHECKED)
    If $f_ChngShowGreyBox <> $f_ShowGreyBox Then
        $f_Change = True
        $f_ShowGreyBox = $f_ChngShowGreyBox
        ConsoleWrite("Debug: $f_ShowGreyBox changed to: " & $f_ShowGreyBox & @CRLF)
    EndIf

    $f_ChngShowChildGreyBox = (BitAND(GUICtrlRead($ChkChildGreyBox), $GUI_CHECKED) = $GUI_CHECKED)
    If $f_ChngShowChildGreyBox <> $f_ShowChildGreyBox Then
        $f_Change = True
        $f_ShowChildGreyBox = $f_ChngShowChildGreyBox
        ConsoleWrite("Debug: $f_ShowChildGreyBox changed to: " & $f_ShowChildGreyBox & @CRLF)
    EndIf

    If $f_Change Then
        $f_Change = False
        If $f_ShowGreyBox Then
            If $f_ShowChildGreyBox Then
                ConsoleWrite("Debug: Show child grey box" & @LF)
                GUISetState(@SW_SHOW, $gChild)
                GUISetState(@SW_HIDE, $gPopup)
            Else
                ConsoleWrite("Debug: Show popup grey box" & @LF)
                GUISetState(@SW_HIDE, $gChild)
                GUISetState(@SW_SHOW, $gPopup)
            EndIf
        Else
            ConsoleWrite("Debug: No grey box" & @LF)
            GUISetState(@SW_HIDE, $gChild)
            GUISetState(@SW_HIDE, $gPopup)
        EndIf
    EndIf

    Sleep(10)
WEnd

Func _ClickMe()
    $tc = 0
    Do
        $tc += 1
        GUICtrlSetData($lab2, $tc)
    Until _IsPressed("01") = 0
EndFunc  ;==>_ClickMe

Func _Quit()
    Exit
EndFunc  ;==>_Quit
Edited by trancexx

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

That's because you misplaced it. You meant something like this:

Yeah, what he said! Thanks for the debug. ^_^

It doesn't need (or want, I think) the gPopup GUI to have the parent handle set (that should only be on gChild). The idea was to try it with an unrelated GUI then make it a child. The unrelated GUI is moved off to the side to show it when the main is active (otherwise it gets buried under main GUI):

$gPopup = GUICreate("gPopup", 150, 120, 550, 20 + 230, $WS_POPUP)

But otherwise that works as I thought it did. With either the popup or child gui displayed, the label works fine because the creation of the child GUI is separate from the mouse event that triggers it (on the checkbox, not the label).

This was what I intended:

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

Const $WS_EX_COMPOSITED = 0x2000000

Opt("GuiOnEventMode", 1)

Global $gMain, $ChkGreyBox, $ChkChildGreyBox, $lab, $lab2, $gChild, $gPopup
Global $f_ShowGreyBox = False, $f_ShowChildGreyBox = False
Global $f_ChngShowGreyBox = False, $f_ChngShowChildGreyBox = False

$gMain = GUICreate("hold left mouse button down when over label 'something'", 300, 300, 200, 200, -1, $WS_EX_COMPOSITED)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
$ChkGreyBox = GUICtrlCreateCheckbox("show grey box", 10, 200, 150, 20)
$ChkChildGreyBox = GUICtrlCreateCheckbox("use child window for grey box", 10, 230, 250, 20)
$lab = GUICtrlCreateLabel("click me", 20, 20, 100, 20)
GUICtrlSetOnEvent(-1, "_ClickMe")
GUICtrlSetBkColor(-1, 0xffffff)
$lab2 = GUICtrlCreateLabel("", 20, 50, 100, 20)
GUICtrlSetBkColor(-1, 0xffffff)
GUISetState()

$gChild = GUICreate("gChild", 150, 120, 120, 20, $WS_CHILD, -1, $gMain)
GUISetBkColor(0x777777)
GUISetState(@SW_HIDE)

$gPopup = GUICreate("gPopup", 150, 120, 550, 20 + 230, $WS_POPUP)
GUISetBkColor(0x777777)
GUISetState(@SW_HIDE)

While 1
    $f_Change = False

    $f_ChngShowGreyBox = (BitAND(GUICtrlRead($ChkGreyBox), $GUI_CHECKED) = $GUI_CHECKED)
    If $f_ChngShowGreyBox <> $f_ShowGreyBox Then
        $f_Change = True
        $f_ShowGreyBox = $f_ChngShowGreyBox
        ConsoleWrite("Debug: $f_ShowGreyBox changed to: " & $f_ShowGreyBox & @CRLF)
    EndIf

    $f_ChngShowChildGreyBox = (BitAND(GUICtrlRead($ChkChildGreyBox), $GUI_CHECKED) = $GUI_CHECKED)
    If $f_ChngShowChildGreyBox <> $f_ShowChildGreyBox Then
        $f_Change = True
        $f_ShowChildGreyBox = $f_ChngShowChildGreyBox
        ConsoleWrite("Debug: $f_ShowChildGreyBox changed to: " & $f_ShowChildGreyBox & @CRLF)
    EndIf

    If $f_Change Then
        $f_Change = False
        If $f_ShowGreyBox Then
            If $f_ShowChildGreyBox Then
                ConsoleWrite("Debug: Show child grey box" & @LF)
                GUISetState(@SW_SHOW, $gChild)
                GUISetState(@SW_HIDE, $gPopup)
            Else
                ConsoleWrite("Debug: Show popup grey box" & @LF)
                GUISetState(@SW_HIDE, $gChild)
                GUISetState(@SW_SHOW, $gPopup)
            EndIf
        Else
            ConsoleWrite("Debug: No grey box" & @LF)
            GUISetState(@SW_HIDE, $gChild)
            GUISetState(@SW_HIDE, $gPopup)
        EndIf
    EndIf

    Sleep(10)
WEnd

Func _ClickMe()
    $tc = 0
    Do
        $tc += 1
        GUICtrlSetData($lab2, $tc)
    Until _IsPressed("01") = 0
EndFunc  ;==>_ClickMe

Func _Quit()
    Exit
EndFunc  ;==>_Quit

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Workaround - for script two posts up - could be changing line 73 from:

If $f_ShowChildGreyBox Then GUISetState(@SW_SHOW, $gChild)

to:

If $f_ShowChildGreyBox Then WinSetState($gChild, 0, @SW_SHOW)
Yes trancexx, that's exactly what I want ^_^

I think GuiSetState should do the same so I think there is something wrong with GuiSetState.

Thank you.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Did you notice the difference in speed when using direct call to ShowWindow; _WinAPI_ShowWindow() and WinSetState()?

Dammit, why is that???

Is it possible that determining if passed parameter is a window handle takes that much?

Maybe something is broken with me? ^_^

edit:

I must comment this:

If BitAND(GUICtrlRead($ChkGreyBox), $GUI_CHECKED) = $GUI_CHECKED Then...

What is the meaning of that? Why like that? That's over...something.

Edited by trancexx

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Did you notice the difference in speed when using direct call to ShowWindow; _WinAPI_ShowWindow() and WinSetState()?

Dammit, why is that???

Is it possible that determining if passed parameter is a window handle takes that much?

Maybe something is broken with me? ^_^

You're right again, _WinAPI_ShowWindow is much faster - thanks.

edit:

I must comment this:

If BitAND(GUICtrlRead($ChkGreyBox), $GUI_CHECKED) = $GUI_CHECKED Then...

What is the meaning of that? Why like that? That's over...something.

GuiCtrlRead will get the state of the check box which might include hidden, checked etc so BitAND(GUICtrlRead($ChkGreyBox), $GUI_CHECKED) will only get the part about the checked state. But I could have said

If BitAND(GUICtrlRead($ChkGreyBox), $GUI_CHECKED) then

but I didn't. No particular reason, just writing as I thought at the time.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 2 weeks later...

About the speed of WinSetState()...

Jpm gave the explanation here.

It's due to default setting of Opt("WinWaitDelay"), and that is 250 ms.

Opt("WinWaitDelay", 0) must be added in order to match speed.

AAh! It all makes sense now ^_^

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
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
 Share

  • Recently Browsing   0 members

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