Jump to content

Multiple Windows Issue


Recommended Posts

Is there a way other then setting focus to the edit box to make the text not highlighted? There is a noticeable flicker using this method. Thanks.

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

Example1()

; example 1
Func Example1()
    Local $msg
    Local $something = "Creates a window that has a thin-line border." & _ 
                    "$WS_POPUP 0x80000000 Creates a pop-up window. This style cannot be used with the WS_CHILD style." & _ 
                    "$WS_CAPTION 0x00C00000 Creates a window that has a title bar (includes the WS_BORDER style)" & _ 
                    "$WS_CLIPCHILDREN 0x02000000 Excludes the area occupied by child windows when drawing occurs within the parent window. This style is used when creating the parent window. "

    $GUI = GUICreate("My GUI", 300, 300) ; will create a dialog box that when displayed is centered
    $btn = Guictrlcreatebutton("Open", 135, 118, 35, 30)
    
    $aTest = WinGetPos("My GUI")
    
    $GUI2 = GUICreate("Second Winder", $aTest[2], $aTest[3] - 32, $aTest[0] + $aTest[2], $aTest[1], $WS_CAPTION)
    $edit = GUICtrlCreateEdit($something, 0, 0, $aTest[2], $aTest[3] - 32, $ES_MULTILINE + $WS_VSCROLL + $ES_WANTRETURN + $ES_READONLY)
    
    GUISetState(@SW_HIDE, $GUI2)
    GUISetState(@SW_SHOW, $GUI)   ; will display an empty dialog box

   ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        
        if $msg = $btn Then
            if Not BitAND(WinGetState("Second Winder"), 2) Then
                GUISetState(@SW_SHOW, $GUI2)
            ;GUICtrlSetState($edit,$GUI_FOCUS)
            Else
                GUISetState(@SW_HIDE, $GUI2)
            EndIf
        EndIf
    WEnd
    GUIDelete()
EndFunc  ;==>Example1
Link to comment
Share on other sites

While 1
        $msg = GUIGetMsg()

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        
        if $msg = $btn Then
            if Not BitAND(WinGetState("Second Winder"), 2) Then
                GUISetState(@SW_SHOW, $GUI2)
        GUICtrlSendMsg($edit, $EM_SETSEL, 0, 0) ; Maybe like this.
            ;GUICtrlSetState($edit,$GUI_FOCUS)
            Else
                GUISetState(@SW_HIDE, $GUI2)
            EndIf
        EndIf
    WEnd

Link to comment
Share on other sites

Nah, it still happens. Setting focus to the edit control and back to a control on the main GUI seems to fix the issue, but seems like a "hacky" way of doing it. Any idea why the text gets highlighted like that?

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

Example1()

; example 1
Func Example1()
    Local $msg
    Local $something = "Creates a window that has a thin-line border." & _
                    "$WS_POPUP 0x80000000 Creates a pop-up window. This style cannot be used with the WS_CHILD style." & _
                    "$WS_CAPTION 0x00C00000 Creates a window that has a title bar (includes the WS_BORDER style)" & _
                    "$WS_CLIPCHILDREN 0x02000000 Excludes the area occupied by child windows when drawing occurs within the parent window. This style is used when creating the parent window. "

    $GUI = GUICreate("My GUI", 300, 300)  ; will create a dialog box that when displayed is centered
    $btn = Guictrlcreatebutton("Open", 135, 118, 35, 30)
   
    $aTest = WinGetPos("My GUI")
   
    $GUI2 = GUICreate("Second Winder", $aTest[2], $aTest[3] - 32, $aTest[0] + $aTest[2], $aTest[1], $WS_CAPTION)
    $edit = GUICtrlCreateEdit($something, 0, 0, $aTest[2], $aTest[3] - 32, $ES_MULTILINE + $WS_VSCROLL + $ES_WANTRETURN + $ES_READONLY)
   
    GUICtrlSetState($edit,$GUI_FOCUS)
    GUICtrlSetState($btn,$GUI_FOCUS)
   
    GUISetState(@SW_HIDE, $GUI2)
    GUISetState(@SW_SHOW, $GUI)       ; will display an empty dialog box
   

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
       
        if $msg = $btn Then
            if Not BitAND(WinGetState("Second Winder"), 2) Then
                GUISetState(@SW_SHOW, $GUI2)
                ;GUICtrlSendMsg($edit,$EM_SETSEL, 0, 0)
                ;GUICtrlSetState($edit,$GUI_FOCUS)
            Else
                GUISetState(@SW_HIDE, $GUI2)
            EndIf
        EndIf
    WEnd
    GUIDelete()
EndFunc   ;==>Example1
Edited by notta
Link to comment
Share on other sites

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

Const $WS_EX_NOACTIVATE = 0x08000000

Example1()

; example 1
Func Example1()
    Local $msg
    Local $something = "Creates a window that has a thin-line border." & _
                    "$WS_POPUP 0x80000000 Creates a pop-up window. This style cannot be used with the WS_CHILD style." & _
                    "$WS_CAPTION 0x00C00000 Creates a window that has a title bar (includes the WS_BORDER style)" & _
                    "$WS_CLIPCHILDREN 0x02000000 Excludes the area occupied by child windows when drawing occurs within the parent window. This style is used when creating the parent window. "

    $GUI = GUICreate("My GUI", 300, 300)  ; will create a dialog box that when displayed is centered
    $btn = Guictrlcreatebutton("Open", 135, 118, 35, 30)
   
    $aTest = WinGetPos("My GUI")
   
    $GUI2 = GUICreate("Second Winder", $aTest[2], $aTest[3] - 32, $aTest[0] + $aTest[2], $aTest[1], $WS_CAPTION)
    $edit = GUICtrlCreateEdit($something, 0, 0, $aTest[2], $aTest[3] - 32, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_WANTRETURN, $ES_READONLY), $WS_EX_NOACTIVATE)
   
    GUICtrlSetState($edit,$GUI_FOCUS)
    GUICtrlSetState($btn,$GUI_FOCUS)
   
    GUISetState(@SW_HIDE, $GUI2)
    GUISetState(@SW_SHOW, $GUI)       ; will display an empty dialog box
   

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
       
        if $msg = $btn Then
            if Not BitAND(WinGetState("Second Winder"), 2) Then
                GUISetState(@SW_SHOW, $GUI2)
            Else
                GUISetState(@SW_HIDE, $GUI2)
            EndIf
        EndIf
    WEnd
    
    GUIDelete()
EndFunc   ;==>Example1

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