Modify

Opened 3 weeks ago

Last modified 3 weeks ago

#4071 assigned Bug

$GUI_ONTOP sends labels to wrong end of z-order

Reported by: MattyD Owned by: Jon
Milestone: Component: AutoIt
Version: 3.3.18.0 Severity: None
Keywords: Cc:

Description

Apologies if this should be a comment in #2287, I wasn't sure if that was still appropriate given the age of the ticket.

Anyway, the $GUI_ONTOP flag seems to send static controls to the wrong end of the z-order. Discussion is here:
https://www.autoitscript.com/forum/topic/213453-gui_ontop-label-controls/

Thanks,
Matt

#include <GUIConstants.au3>
#include <WinAPI.au3>

_Example()

Func _Example()
        Local $hGUI = GUICreate("Test", 300, 200)
        GUISetState()

        GUICtrlCreateLabel("Label 1", 30, 30, 200, 100, $WS_CLIPSIBLINGS)
        GUICtrlSetBkColor(-1, 0xFF0000)

        GUICtrlCreateLabel("Label 2", 50, 45, 200, 100, $WS_CLIPSIBLINGS)
        GUICtrlSetBkColor(-1, 0x00FF00)

        GUICtrlCreateButton("Button 1", 70, 60, 200, 100, $WS_CLIPSIBLINGS)
        GUICtrlSetBkColor(-1, 0x0000FF)

        GUICtrlCreateEdit("Edit 1", 90, 75, 200, 100, $WS_CLIPSIBLINGS)
        GUICtrlSetBkColor(-1, 0xFFFF00)

        Local $aMsg, $hCtrl, $idCtrl
        Local $tPoint = DllStructCreate($tagPoint)
        While 1
                $aMsg = GUIGetMsg(1)
                Switch $aMsg[0]
                        Case $GUI_EVENT_PRIMARYDOWN
                                ;Get control under the mouse.
                                $tPoint.X = $aMsg[3]
                                $tPoint.Y = $aMsg[4]
                                _WinAPI_ClientToScreen($aMsg[1], $tPoint)
                                $hCtrl = _WinAPI_WindowFromPoint($tPoint)
                                $idCtrl = _WinAPI_GetDlgCtrlID($hCtrl)
                                If Not $idCtrl Then ContinueLoop

                                ConsoleWrite(StringFormat("Clicked on CtrlID: %d (%s)", $idCtrl, GUICtrlRead($idCtrl))& @CRLF)

                                ;Labels go to the back, Button & Edit controls come to the front
                                GUICtrlSetState($idCtrl, $GUI_ONTOP)

                                ;All controls come to the front
;~                              _WinAPI_BringWindowToTop($hCtrl)

;~                              ;All controls come to the front
;~                              _WinAPI_SetWindowPos($hCtrl, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_NOMOVE, $SWP_NOSIZE))

                        Case $GUI_EVENT_CLOSE
                                ExitLoop
                EndSwitch
        WEnd

        GUIDelete($hGUI)
EndFunc

Attachments (0)

Change History (4)

comment:1 by J-Paul Mesnage, 3 weeks ago

Hi,
The proposed go around are equivalent to revert the #2287 But now how to have both working?

Thanks for the help

comment:2 by J-Paul Mesnage, 3 weeks ago

Hi,
I found a solution for the use of $WS_CLIPSIBLINGS
I am not sure why the solution for #2247 need to use an insertion to botom for label without the $WS_CLIPSIBLINGS
Fix sent to Jon

comment:3 by J-Paul Mesnage, 3 weeks ago

Owner: set to Jon
Status: newassigned

comment:4 by pixelsearch, 3 weeks ago

Well done jpm

Modify Ticket

Action
as assigned The owner will remain Jon.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.