Jump to content

Tabbing between parrent control and child controls


vickerps
 Share

Recommended Posts

Hi

I'm wondering if it is possible to tab cycle between controls that are on different windows.

currently if the child window get focus and I can tab across all of its control but the tab cycle ignores the buttons that exist on the parent windows.

 

$gForm = GuiCreate($gGuiTitle & ' ' & StringUpper($gCustomer),$gFW,$gFH,$gFX,$gFY,BITOR($WS_CAPTION,$WS_SYSMENU,$WS_MINIMIZEBOX))
        GUICtrlSetState($gForm,$GUI_DISABLE)
        GUISetBkColor(0xF0F0F0,$gForm)
        GUICtrlSetDefBkColor(0xF0F0F0)
    $Hdr = GUICtrlCreateGraphic(0,70 ,$gFW, 5,$SS_SUNKEN)
    $Lbl_InstVer = GUICtrlCreateLabel('v' & FileGetVersion(@ScriptFullPath,'FileVersion'),10,0,$gFW-20,12,$SS_RIGHT)
        GUICtrlSetState($Lbl_InstVer,$GUI_DISABLE)
        GUICtrlSetFont($Lbl_InstVer,$gFontSizeDetailSmall,$FW_NORMAL,0,$gFontName)
    $gLbl_Title = GUICtrlCreateLabel('',10,20,$gFW-20,35)
        GUICtrlSetFont($gLbl_Title,$gFontSizeHeaderLarge,$FW_NORMAL,0,$gFontName)
    $Ftr = GUICtrlCreateGraphic(0,$gFH-55,$gFW,5,$SS_SUNKEN)
    $gB_Button1 = GUICtrlCreateButton('&Next',$gFW-102,$gFH-43,100,40,$BS_DEFPUSHBUTTON)
        GUICtrlSetBkColor($gB_Button1,0xF0F0F0)
        GUICtrlSetFont($gB_Button1,$gFontSizeButtonNormal)
    $gB_Button2 = GUICtrlCreateButton('&Reject',$gFW-205,$gFH-43,100,40,$BS_DEFPUSHBUTTON)
        GUICtrlSetBkColor($gB_Button2,0xF0F0F0)
        GUICtrlSetFont($gB_Button2,$gFontSizeButtonNormal)
        GUICtrlSetState($gB_Button2,$GUI_Hide)
    $gB_Button3 = GUICtrlCreateButton('&Log',05,$gFH-43,100,40,$BS_DEFPUSHBUTTON)
        GUICtrlSetBkColor($gB_Button3,0xF0F0F0)
        GUICtrlSetFont($gB_Button3,$gFontSizeButtonNormal)
        GUICtrlSetState($gB_Button3,$GUI_Hide)

    GUISetState(@SW_SHOW,$gForm)

 

$F = GuiCreate('',$FW,$FH,$FX,$FY,$WS_Popup,$WS_EX_MDICHILD,$gForm)
    GUICtrlSetData($gLbl_Title,$Title)
    GUISetBkColor(0xF0F0F0,$F)
    GUISetFont($gFontSizeDetailLarge,$FW_NORMAL,0,$gFontName)
    $Lbl_Message1 = GUICtrlCreateLabel($Message1,10,10,$FW-20,40)
    $Lbl_Computername = GUICtrlCreateLabel('&Computer name:',60,70,130,20)
        $I_ComputerName = GUICtrlCreateInput($A_ComputerName,200,70,150,25,$ES_UPPERCASE)
    $Lbl_WorkGroup = GUICtrlCreateLabel('&WorkGroup:',60,100,130,20)
        $I_WorkGroup = GUICtrlCreateInput($A_WorkGroup,200,100,150,25,$ES_UPPERCASE)
    $Lbl_Message2 = GUICtrlCreateLabel($Message2,10,140,$FW-20,40)
    $Lbl_IP = GUICtrlCreateLabel('Static &IP address:',60,200,130,20)
        $I_IP = _GUICtrlIpAddress_Create ($F,200,200,150,25)
            _GUICtrlIpAddress_SetFont($I_IP,"Arial",12)
            IF NOT ($A_IP='') THEN _GUICtrlIpAddress_Set ($I_IP,$A_IP)
    $Lbl_Subnet = GUICtrlCreateLabel('Subnet &mask:',60,230,130,25)
        $I_Subnet = _GUICtrlIpAddress_Create($F,200,230,150,25)
            _GUICtrlIpAddress_SetFont($I_Subnet,"Arial",12)
            IF NOT ($A_Subnet='') THEN _GUICtrlIpAddress_Set ($I_Subnet,$A_Subnet)
    $Lbl_Gateway= GUICtrlCreateLabel('Default &gateway:',60,260,130,20)
        $I_Gateway = _GUICtrlIpAddress_Create($F,200,260,150,25)
            _GUICtrlIpAddress_SetFont($I_Gateway,"Arial",12)
            IF NOT ($A_Gateway='') THEN _GUICtrlIpAddress_Set ($I_Gateway,$A_Gateway)
    $Lbl_PDNS= GUICtrlCreateLabel('&Preferred DNS:',60,290,130,20)
        $I_PDNS = _GUICtrlIpAddress_Create($F,200,290,150,25,$WS_TABSTOP)
            _GUICtrlIpAddress_SetFont($I_PDNS,"Arial",12)
            IF NOT ($A_PDNS='') THEN _GUICtrlIpAddress_Set ($I_PDNS,$A_PDNS)
    $Lbl_ADNS= GUICtrlCreateLabel('&Alternate DNS:',60,320,130,20)
        $I_ADNS = _GUICtrlIpAddress_Create($F,200,320,150,25,$WS_TABSTOP)
            _GUICtrlIpAddress_SetFont($I_ADNS,"Arial",12)
        IF NOT ($A_ADNS='') THEN _GUICtrlIpAddress_Set ($I_ADNS,$A_ADNS)

 

 

 

 

 

 

 

Link to comment
Share on other sites

  • Moderators

vickerps,

Try adding the $WS_EX_CONTROLPARENT style. However, I must warn you that AutoIt actually uses that extended style for other purposes (a design decision taken long ago and too deep in the code to remove) which might give you some unwanted secondary effects - try it and see.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Thanks for your post but no it doesn't solve the issue. In fact by adding $WS_EX_CONTROLPARENT it detaches the child from the parent so it is moveable which something I don't want.

Unless anything has a better idea I think I'm going to have to create the buttons on the child form instead of the parent which is something I didn't want to do.

here a workable example of what I am trying to achieve.

All I want is the tab order to include the button on the parent form.

 

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.10.2
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

Global $gFontName = 'Tahoma'
Global $gFontSizeHeaderLarge = 18
Global $gFontSizeDetailLarge = 12
Global $gFontSizeDetailNormal = 10
Global $gFontSizeDetailSmall = 8
Global $gFontSizeButtonNormal = 9
Global $gFontSizeButtonSmall = 8

Global $gAnwserFile = @ScriptDir &'\'& StringTrimRight(@ScriptName,3) & 'ini'

#INCLUDE-ONCE
#INCLUDE <Array.au3>
#INCLUDE <ButtonConstants.au3>
#INCLUDE <ComboConstants.au3>
#INCLUDE <EditConstants.au3>
#INCLUDE <File.au3>
#INCLUDE <FontConstants.au3>
#INCLUDE <GUIConstants.au3>
#INCLUDE <GUIConstantsEx.au3>
#INCLUDE <GuiEdit.au3>
#INCLUDE <GuiIPAddress.au3>
#INCLUDE <ListviewConstants.au3>
#INCLUDE <Process.au3>
#INCLUDE <ProgressConstants.au3>
#INCLUDE <StaticConstants.au3>
#INCLUDE <_SQL.au3>
#INCLUDE <UpdownConstants.au3>
#INCLUDE <WinAPI.au3>
#INCLUDE <WindowsConstants.au3>

    IF @DesktopWidth = 800  AND @DesktopHeight = 600 Then
        $gFW = @DesktopWidth/1.2
        $gFH = @DesktopHeight/1.25
        $gFX = @DesktopWidth/9.5
        $gFY = @DesktopHeight/11
    ElseIf @DesktopWidth = 1024  AND @DesktopHeight = 768 Then
        $gFW = @DesktopWidth/1.4
        $gFH = @DesktopHeight/1.6
        $gFX = @DesktopWidth/6
        $gFY = @DesktopHeight/5
    ElseIf @DesktopWidth = 1280 AND @DesktopHeight = 720 Then
        $gFW = @DesktopWidth/1.6
        $gFH = @DesktopHeight/1.5
        $gFX = @DesktopWidth/4.5
        $gFY = @DesktopHeight/6
    ElseIf @DesktopWidth = 1280 AND @DesktopHeight = 1022 Then
        $gFW = @DesktopWidth/1.6
        $gFH = @DesktopHeight/2.1
        $gFX = @DesktopWidth/4.5
        $gFY = @DesktopHeight/6
    ElseIf @DesktopWidth = 1280 AND @DesktopHeight = 1024 Then
        $gFW = @DesktopWidth/1.6
        $gFH = @DesktopHeight/2.1
        $gFX = @DesktopWidth/4.5
        $gFY = @DesktopHeight/6
    ElseIf @DesktopWidth = 1920 AND @DesktopHeight = 1080 Then
        $gFW = @DesktopWidth/2
        $gFH = @DesktopHeight/1.9
        $gFX = @DesktopWidth/3.5
        $gFY = @DesktopHeight/4
    Else
        Msgbox(16,'Resolution not supported','This resolution ( '& @DesktopWidth & 'x' & @DesktopHeight & ' ) has not been predicted.')
        $gFW = @DesktopWidth/1.2
        $gFH = @DesktopHeight/1.25
        $gFX = @DesktopWidth/9.5
        $gFY = @DesktopHeight/11
    Endif


$gWorkingFile = @ScriptDir &'\'& StringTrimRight(@ScriptName,4) & '_Answers.log'
$gLookupFile = StringStripWS(IniRead($gAnwserFile,'General Settings','LookupFile',@ScriptDir & '\Lookup.ini'),3)
$gLog = StringStripWS(IniRead($gAnwserFile,'General Settings','Log', StringTrimRight(@ScriptName,4) & '_Actions.log'),3)
$gGuiTitle=StringStripWS(IniRead($gAnwserFile,'General Settings','GuiTitle',''),3)
$gCustomer=StringStripWS(IniRead($gAnwserFile,'General Settings','Customer',''),3)
$gComputerNamePrefix=StringStripWS(IniRead($gAnwserFile,'General Settings','ComputerNamePrefix',''),3)
$gComputerNameDivider=StringStripWS(IniRead($gAnwserFile,'General Settings','ComputerNameDivider',''),3)


$gForm = GuiCreate($gGuiTitle & ' ' & StringUpper($gCustomer),$gFW,$gFH,$gFX,$gFY,BITOR($WS_CAPTION,$WS_SYSMENU,$WS_MINIMIZEBOX))
        GUICtrlSetState($gForm,$GUI_DISABLE)
        GUISetBkColor(0xF0F0F0,$gForm)
        GUICtrlSetDefBkColor(0xF0F0F0)
    $Hdr = GUICtrlCreateGraphic(0,70 ,$gFW, 5,$SS_SUNKEN)
    $Lbl_InstVer = GUICtrlCreateLabel('v' & FileGetVersion(@ScriptFullPath,'FileVersion'),10,0,$gFW-20,12,$SS_RIGHT)
        GUICtrlSetState($Lbl_InstVer,$GUI_DISABLE)
        GUICtrlSetFont($Lbl_InstVer,$gFontSizeDetailSmall,$FW_NORMAL,0,$gFontName)
    $gLbl_Title = GUICtrlCreateLabel('',10,20,$gFW-20,35)
        GUICtrlSetFont($gLbl_Title,$gFontSizeHeaderLarge,$FW_NORMAL,0,$gFontName)
    $Ftr = GUICtrlCreateGraphic(0,$gFH-55,$gFW,5,$SS_SUNKEN)
    $gB_Button1 = GUICtrlCreateButton('&Next',$gFW-102,$gFH-43,100,40,$BS_DEFPUSHBUTTON)
        GUICtrlSetBkColor($gB_Button1,0xF0F0F0)
        GUICtrlSetFont($gB_Button1,$gFontSizeButtonNormal)
    $gB_Button2 = GUICtrlCreateButton('&Reject',$gFW-205,$gFH-43,100,40,$BS_DEFPUSHBUTTON)
        GUICtrlSetBkColor($gB_Button2,0xF0F0F0)
        GUICtrlSetFont($gB_Button2,$gFontSizeButtonNormal)
        GUICtrlSetState($gB_Button2,$GUI_Hide)
    $gB_Button3 = GUICtrlCreateButton('&Log',05,$gFH-43,100,40,$BS_DEFPUSHBUTTON)
        GUICtrlSetBkColor($gB_Button3,0xF0F0F0)
        GUICtrlSetFont($gB_Button3,$gFontSizeButtonNormal)
        GUICtrlSetState($gB_Button3,$GUI_Hide)

    GUISetState(@SW_SHOW,$gForm)

    $Chk = Child($gFW,$gFH-140,0,80)

Func  Child($FW,$FH,$FX,$FY)
    $F = GuiCreate('',$FW,$FH,$FX,$FY,$WS_Popup,$WS_EX_MDICHILD,$gForm)
    GUICtrlSetData($gLbl_Title,'')
    GUISetBkColor(0xF0F0F0,$F)
    GUISetFont($gFontSizeDetailLarge,$FW_NORMAL,0,$gFontName)
    $Lbl_Message1 = GUICtrlCreateLabel('',10,10,$FW-20,40)
    $Lbl_Computername = GUICtrlCreateLabel('&Computer name:',60,70,130,20)
        $I_ComputerName = GUICtrlCreateInput(@ComputerName,200,70,150,25,$ES_UPPERCASE)
    $Lbl_WorkGroup = GUICtrlCreateLabel('&WorkGroup:',60,100,130,20)
        $I_WorkGroup = GUICtrlCreateInput('',200,100,150,25,$ES_UPPERCASE)
    $Lbl_Message2 = GUICtrlCreateLabel('',10,140,$FW-20,40)
    $Lbl_IP = GUICtrlCreateLabel('Static &IP address:',60,200,130,20)
        $I_IP = _GUICtrlIpAddress_Create ($F,200,200,150,25)
            _GUICtrlIpAddress_SetFont($I_IP,"Arial",12)

    $Lbl_Subnet = GUICtrlCreateLabel('Subnet &mask:',60,230,130,25)
        $I_Subnet = _GUICtrlIpAddress_Create($F,200,230,150,25)
            _GUICtrlIpAddress_SetFont($I_Subnet,"Arial",12)

    $Lbl_Gateway= GUICtrlCreateLabel('Default &gateway:',60,260,130,20)
        $I_Gateway = _GUICtrlIpAddress_Create($F,200,260,150,25)
            _GUICtrlIpAddress_SetFont($I_Gateway,"Arial",12)

    $Lbl_PDNS= GUICtrlCreateLabel('&Preferred DNS:',60,290,130,20)
        $I_PDNS = _GUICtrlIpAddress_Create($F,200,290,150,25,$WS_TABSTOP)
            _GUICtrlIpAddress_SetFont($I_PDNS,"Arial",12)

    $Lbl_ADNS= GUICtrlCreateLabel('&Alternate DNS:',60,320,130,20)
        $I_ADNS = _GUICtrlIpAddress_Create($F,200,320,150,25,$WS_TABSTOP)
            _GUICtrlIpAddress_SetFont($I_ADNS,"Arial",12)

        GUISetState(@SW_SHOW,$F)
        WHILE 1
            $Msg=GUIGetMsg()
            Switch $Msg
                Case $GUI_EVENT_CLOSE
                    $RVal = 1
                    ExitLoop
                Case $gB_Button1
                    ExitLoop
                EndSwitch
        WEnd
EndFunc

 

 

 

Link to comment
Share on other sites

  • Moderators

vickerps,

In fact by adding $WS_EX_CONTROLPARENT it detaches the child from the parent so it is moveable which something I don't want

​That was the "unwanted secondary effect" I spoke of.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

vickerps, This can be done, but you will have to handle the tab key and the status of the shift key manually:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.10.2
 Author:         myName

 Script Function:
  Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

Global $gFontName = 'Tahoma'
Global $gFontSizeHeaderLarge = 18
Global $gFontSizeDetailLarge = 12
Global $gFontSizeDetailNormal = 10
Global $gFontSizeDetailSmall = 8
Global $gFontSizeButtonNormal = 9
Global $gFontSizeButtonSmall = 8

Global $gAnwserFile = @ScriptDir &'\'& StringTrimRight(@ScriptName,3) & 'ini'

Global $idTabPress, $F, $gForm
Global Const $tagMSG = "hwnd hwnd;uint message;wparam wParam;lparam lParam;dword time;int X;int Y"

#INCLUDE-ONCE
#INCLUDE <Array.au3>
#INCLUDE <ButtonConstants.au3>
#INCLUDE <ComboConstants.au3>
#INCLUDE <EditConstants.au3>
#INCLUDE <File.au3>
#INCLUDE <FontConstants.au3>
#INCLUDE <GUIConstants.au3>
#INCLUDE <GUIConstantsEx.au3>
#INCLUDE <GuiEdit.au3>
#INCLUDE <GuiIPAddress.au3>
#INCLUDE <ListviewConstants.au3>
#INCLUDE <Process.au3>
#INCLUDE <ProgressConstants.au3>
#INCLUDE <StaticConstants.au3>
;#INCLUDE <_SQL.au3>
#INCLUDE <UpdownConstants.au3>
#INCLUDE <WinAPI.au3>
#INCLUDE <WindowsConstants.au3>
#include <WinAPIvkeysConstants.au3>

  IF @DesktopWidth = 800  AND @DesktopHeight = 600 Then
    $gFW = @DesktopWidth/1.2
    $gFH = @DesktopHeight/1.25
    $gFX = @DesktopWidth/9.5
    $gFY = @DesktopHeight/11
  ElseIf @DesktopWidth = 1024  AND @DesktopHeight = 768 Then
    $gFW = @DesktopWidth/1.4
    $gFH = @DesktopHeight/1.6
    $gFX = @DesktopWidth/6
    $gFY = @DesktopHeight/5
  ElseIf @DesktopWidth = 1280 AND @DesktopHeight = 720 Then
    $gFW = @DesktopWidth/1.6
    $gFH = @DesktopHeight/1.5
    $gFX = @DesktopWidth/4.5
    $gFY = @DesktopHeight/6
  ElseIf @DesktopWidth = 1280 AND @DesktopHeight = 1022 Then
    $gFW = @DesktopWidth/1.6
    $gFH = @DesktopHeight/2.1
    $gFX = @DesktopWidth/4.5
    $gFY = @DesktopHeight/6
  ElseIf @DesktopWidth = 1280 AND @DesktopHeight = 1024 Then
    $gFW = @DesktopWidth/1.6
    $gFH = @DesktopHeight/2.1
    $gFX = @DesktopWidth/4.5
    $gFY = @DesktopHeight/6
  ElseIf @DesktopWidth = 1920 AND @DesktopHeight = 1080 Then
    $gFW = @DesktopWidth/2
    $gFH = @DesktopHeight/1.9
    $gFX = @DesktopWidth/3.5
    $gFY = @DesktopHeight/4
  Else
    Msgbox(16,'Resolution not supported','This resolution ( '& @DesktopWidth & 'x' & @DesktopHeight & ' ) has not been predicted.')
    $gFW = @DesktopWidth/1.2
    $gFH = @DesktopHeight/1.25
    $gFX = @DesktopWidth/9.5
    $gFY = @DesktopHeight/11
  Endif


$gWorkingFile = @ScriptDir &'\'& StringTrimRight(@ScriptName,4) & '_Answers.log'
$gLookupFile = StringStripWS(IniRead($gAnwserFile,'General Settings','LookupFile',@ScriptDir & '\Lookup.ini'),3)
$gLog = StringStripWS(IniRead($gAnwserFile,'General Settings','Log', StringTrimRight(@ScriptName,4) & '_Actions.log'),3)
$gGuiTitle=StringStripWS(IniRead($gAnwserFile,'General Settings','GuiTitle',''),3)
$gCustomer=StringStripWS(IniRead($gAnwserFile,'General Settings','Customer',''),3)
$gComputerNamePrefix=StringStripWS(IniRead($gAnwserFile,'General Settings','ComputerNamePrefix',''),3)
$gComputerNameDivider=StringStripWS(IniRead($gAnwserFile,'General Settings','ComputerNameDivider',''),3)


$gForm = GuiCreate($gGuiTitle & ' ' & StringUpper($gCustomer),$gFW,$gFH,$gFX,$gFY,BITOR($WS_CAPTION,$WS_SYSMENU,$WS_MINIMIZEBOX))
    GUICtrlSetState($gForm,$GUI_DISABLE)
    GUISetBkColor(0xF0F0F0,$gForm)
    GUICtrlSetDefBkColor(0xF0F0F0)
  $Hdr = GUICtrlCreateGraphic(0,70 ,$gFW, 5,$SS_SUNKEN)
  $Lbl_InstVer = GUICtrlCreateLabel('v' & FileGetVersion(@ScriptFullPath,'FileVersion'),10,0,$gFW-20,12,$SS_RIGHT)
    GUICtrlSetState($Lbl_InstVer,$GUI_DISABLE)
    GUICtrlSetFont($Lbl_InstVer,$gFontSizeDetailSmall,$FW_NORMAL,0,$gFontName)
  $gLbl_Title = GUICtrlCreateLabel('',10,20,$gFW-20,35)
    GUICtrlSetFont($gLbl_Title,$gFontSizeHeaderLarge,$FW_NORMAL,0,$gFontName)
  $Ftr = GUICtrlCreateGraphic(0,$gFH-55,$gFW,5,$SS_SUNKEN)
  $gB_Button3 = GUICtrlCreateButton('&Log',05,$gFH-43,100,40,$BS_DEFPUSHBUTTON)
    GUICtrlSetBkColor($gB_Button3,0xF0F0F0)
    GUICtrlSetFont($gB_Button3,$gFontSizeButtonNormal)
    ;GUICtrlSetState($gB_Button3,$GUI_Hide)
  $gB_Button2 = GUICtrlCreateButton('&Reject',$gFW-205,$gFH-43,100,40,$BS_DEFPUSHBUTTON)
    GUICtrlSetBkColor($gB_Button2,0xF0F0F0)
    GUICtrlSetFont($gB_Button2,$gFontSizeButtonNormal)
    ;GUICtrlSetState($gB_Button2,$GUI_Hide)
  $gB_Button1 = GUICtrlCreateButton('&Next',$gFW-102,$gFH-43,100,40,$BS_DEFPUSHBUTTON)
    GUICtrlSetBkColor($gB_Button1,0xF0F0F0)
    GUICtrlSetFont($gB_Button1,$gFontSizeButtonNormal)

  ; Catch window messages
  Local $hMessageHandler = DllCallbackRegister( "MessageHandler", "long", "int;wparam;lparam" )
  Local $hMessageHook = _WinAPI_SetWindowsHookEx( $WH_GETMESSAGE, DllCallbackGetPtr( $hMessageHandler ), 0, _WinAPI_GetCurrentThreadId() )
  $idTabPress = GUICtrlCreateDummy()

  GUISetState(@SW_SHOW,$gForm)

  $Chk = Child($gFW,$gFH-140,0,80)

  _WinAPI_UnhookWindowsHookEx( $hMessageHook )

Func  Child($FW,$FH,$FX,$FY)
  $F = GuiCreate('',$FW,$FH,$FX,$FY,$WS_Popup,$WS_EX_MDICHILD,$gForm)
   GUICtrlSetData($gLbl_Title,'')
  GUISetBkColor(0xF0F0F0,$F)
  GUISetFont($gFontSizeDetailLarge,$FW_NORMAL,0,$gFontName)
  $Lbl_Message1 = GUICtrlCreateLabel('',10,10,$FW-20,40)
  $Lbl_Computername = GUICtrlCreateLabel('&Computer name:',60,70,130,20)
    $I_ComputerName = GUICtrlCreateInput(@ComputerName,200,70,150,25,$ES_UPPERCASE)
  $Lbl_WorkGroup = GUICtrlCreateLabel('&WorkGroup:',60,100,130,20)
    $I_WorkGroup = GUICtrlCreateInput('',200,100,150,25,$ES_UPPERCASE)
  $Lbl_Message2 = GUICtrlCreateLabel('',10,140,$FW-20,40)
  $Lbl_IP = GUICtrlCreateLabel('Static &IP address:',60,200,130,20)
    $I_IP =  _GUICtrlIpAddress_Create ($F,200,200,150,25)
      _GUICtrlIpAddress_SetFont($I_IP,"Arial",12)

  $Lbl_Subnet = GUICtrlCreateLabel('Subnet &mask:',60,230,130,25)
    $I_Subnet = _GUICtrlIpAddress_Create($F,200,230,150,25)
      _GUICtrlIpAddress_SetFont($I_Subnet,"Arial",12)

  $Lbl_Gateway= GUICtrlCreateLabel('Default &gateway:',60,260,130,20)
    $I_Gateway = _GUICtrlIpAddress_Create($F,200,260,150,25)
      _GUICtrlIpAddress_SetFont($I_Gateway,"Arial",12)

  $Lbl_PDNS= GUICtrlCreateLabel('&Preferred DNS:',60,290,130,20)
    $I_PDNS = _GUICtrlIpAddress_Create($F,200,290,150,25,$WS_TABSTOP)
      _GUICtrlIpAddress_SetFont($I_PDNS,"Arial",12)

  $Lbl_ADNS= GUICtrlCreateLabel('&Alternate DNS:',60,320,130,20)
    $I_ADNS = _GUICtrlIpAddress_Create($F,200,320,150,25,$WS_TABSTOP)
      _GUICtrlIpAddress_SetFont($I_ADNS,"Arial",12)

    GUISetState(@SW_SHOW,$F)
    WHILE 1
      $Msg=GUIGetMsg()
      Switch $Msg
        Case $idTabPress
          Local $sCtrlOld = GUICtrlRead( $idTabPress )
          Switch $sCtrlOld
            Case "Edit22"
              ControlFocus( $gForm, "", "[ClassNN:Button1]" )
            Case "Button3"
              ControlFocus( $F, "", "[ClassNN:Edit1]" )
            Case "Edit1Shift"
              ControlFocus( $gForm, "", "[ClassNN:Button3]" )
            Case "Button1Shift"
              ControlFocus( $F, "", "[ClassNN:Edit22]" )
          EndSwitch
          Local $sCtrlNew = ControlGetFocus( $F )
          If $sCtrlNew = "" Then $sCtrlNew = ControlGetFocus( $gForm )
          ConsoleWrite( "Old: " & $sCtrlOld & @CRLF )
          ConsoleWrite( "New: " & $sCtrlNew & @CRLF & @CRLF )

        Case $GUI_EVENT_CLOSE
          $RVal = 1
          ExitLoop
        Case $gB_Button1
          ExitLoop
        EndSwitch
    WEnd
EndFunc

Func MessageHandler( $nCode, $wParam, $lParam )

  If $nCode < 0 Then Return 0

  Local Static $fShift = False
  Local $tMSG = DllStructCreate( $tagMSG, $lParam )
  Local $iMsg = DllStructGetData( $tMSG, "message" )

  Switch $iMsg
    Case $WM_KEYDOWN
      Switch DllStructGetData( $tMSG, "wParam" )
        Case $VK_TAB
          Local $sCtrl = ControlGetFocus( $F )
          If $sCtrl = "" Then $sCtrl = ControlGetFocus( $gForm )
          $sCtrl &= ( $fShift ? "Shift" : "" )
          GUICtrlSendToDummy( $idTabPress, $sCtrl )
          ConsoleWrite( "TabPress" & @CRLF )
        Case $VK_SHIFT
          $fShift = True
      EndSwitch

    Case $WM_KEYUP
      Switch DllStructGetData( $tMSG, "wParam" )
        Case $VK_SHIFT
          $fShift = False
      EndSwitch
  EndSwitch

  Return 0

EndFunc

 

Link to comment
Share on other sites

  • 4 years later...

I was trying to use GUISetAccelerators function, but unable to get good result:

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

;Create a GUI.
Local $hGUI1 = GUICreate("Example GUI1")
;Create a button.
Local $iButton1 = GUICtrlCreateButton("Button1", 10, 10, 80, 22)

;Melba23
;https://www.autoitscript.com/forum/topic/182492-guilistviewex-bugfix-version-26-apr-19/?do=findComment&comment=1431229
Global $cTabPressed = GUICtrlCreateDummy() ; Create a dummy to link with the acceleerator key

;Display the GUI
GUISetState(@SW_SHOW, $hGUI1)

;Set the accelerator key
Global $aAccelKeys[1][2] = [["{TAB}", $cTabPressed]]
GUISetAccelerators($aAccelKeys)

;Create a GUI.
Local $hGUI2 = GUICreate("Example GUI2", 300, 300, -1, -1, -1, $WS_EX_MDICHILD, $hGUI1)

$cInput_1 = GUICtrlCreateInput("", 10, 10, 100,20)
$cInput_2 = GUICtrlCreateInput("", 10, 50, 100,20)

;Create a button.
Local $iButton2 = GUICtrlCreateButton("Button2", 10, 80, 80, 22)

;Melba23
;https://www.autoitscript.com/forum/topic/182492-guilistviewex-bugfix-version-26-apr-19/?do=findComment&comment=1431229
Global $cTabPressed2 = GUICtrlCreateDummy() ; Create a dummy to link with the acceleerator key

;Display the GUI
GUISetState(@SW_SHOW, $hGUI2)

;Set the accelerator key
Local $aAccelKeys2[1][2] = [["{TAB}", $cTabPressed2]]
GUISetAccelerators($aAccelKeys2)

;Initialize a Local variable.
Local $aMsg = 0

While 1
   ;Assign to $aMsg the advanced GUI messages.
   $aMsg = GUIGetMsg(1)

   ;Switch from GUIs
   Switch $aMsg[1]
      Case $hGUI1
         ;The event comes from the GUI1
         ;Switch from event ID
         Switch $aMsg[0]
            Case $GUI_EVENT_CLOSE
               ExitLoop
            Case $iButton1
               MsgBox(0, "", "Button1 clicked.")
            Case $cTabPressed ; When accelerator fired.... <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
               ;Melba23
               ;https://www.autoitscript.com/forum/topic/170605-trigger-input-only-when-hitting-enter/?do=findComment&comment=1247293
               ;Check input has focus
               If _WinAPI_GetFocus() = GUICtrlGetHandle($iButton1) Then
                  GUISwitch($hGUI2)
                  GUISetState(@SW_DISABLE, $hGUI1)
                  GUISetState(@SW_ENABLE, $hGUI2)
                  GUICtrlSetState($iButton2, $GUI_FOCUS)
               EndIf
         EndSwitch
      Case $hGUI2
         ;The event comes from the GUI2
         ;Switch from event ID
         Switch $aMsg[0]
            Case $GUI_EVENT_CLOSE
               GUIDelete($hGUI2)
            Case $iButton2
               MsgBox(0, "", "Button2 clicked.")
            Case $cTabPressed2 ; When accelerator fired.... <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
               ;Melba23
               ;https://www.autoitscript.com/forum/topic/170605-trigger-input-only-when-hitting-enter/?do=findComment&comment=1247293
               ;Check input has focus
               If _WinAPI_GetFocus() = GUICtrlGetHandle($iButton2) Then
                  GUISwitch($hGUI1)
                  GUISetState(@SW_DISABLE, $hGUI2)
                  GUISetState(@SW_ENABLE, $hGUI1)
                  GUICtrlSetState($iButton1, $GUI_FOCUS)
               ElseIf _WinAPI_GetFocus() = GUICtrlGetHandle($cInput_1) Then
                  GUICtrlSetState($cInput_2, $GUI_FOCUS)
               ElseIf _WinAPI_GetFocus() = GUICtrlGetHandle($cInput_2) Then
                  GUICtrlSetState($iButton2, $GUI_FOCUS)
               EndIf
         EndSwitch
  EndSwitch
WEnd

 

Link to comment
Share on other sites

@robertocm Here how I would simplify your GUIs :

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

;Create a GUI.
Local $hGUI1 = GUICreate("Example GUI1")
;Create a button.
Local $iButton1 = GUICtrlCreateButton("Button1", 10, 10, 80, 22)

;Display the GUI
GUISetState(@SW_SHOW, $hGUI1)

;Set the accelerator key
Global $aAccelKeys[1][2] = [["{TAB}", $iButton1]]
GUISetAccelerators($aAccelKeys)

;Create a GUI.
Local $hGUI2 = GUICreate("Example GUI2", 300, 300, -1, -1, -1) ;, $WS_EX_MDICHILD, $hGUI1)

$cInput_1 = GUICtrlCreateInput("", 10, 10, 100, 20)
$cInput_2 = GUICtrlCreateInput("", 10, 50, 100, 20)

;Create a button.
Local $iButton2 = GUICtrlCreateButton("Button2", 10, 80, 80, 22)


;Set the accelerator key
Local $aAccelKeys2[1][2] = [["{TAB}", $iButton2]]
GUISetAccelerators($aAccelKeys2)

;Initialize a Local variable.
Local $aMsg = 0

While 1
  ;Assign to $aMsg the advanced GUI messages.
  $aMsg = GUIGetMsg(1)

  ;Switch from GUIs
  Switch $aMsg[1]
    Case $hGUI1
      ;The event comes from the GUI1
      ;Switch from event ID
      Switch $aMsg[0]
        Case $GUI_EVENT_CLOSE
          ExitLoop
        Case $iButton1
          GUISwitch($hGUI2)
          GUISetState(@SW_DISABLE, $hGUI1)
          GUISetState(@SW_SHOW, $hGUI2)
          GUICtrlSetState($iButton2, $GUI_FOCUS)
      EndSwitch
    Case $hGUI2
      ;The event comes from the GUI2
      ;Switch from event ID
      Switch $aMsg[0]
        Case $GUI_EVENT_CLOSE, $iButton2
          If $aMsg[0] = $GUI_EVENT_CLOSE or _WinAPI_GetFocus() = GUICtrlGetHandle($iButton2) Then
            GUISwitch($hGUI1)
            GUISetState(@SW_HIDE, $hGUI2)
            GUISetState(@SW_ENABLE, $hGUI1)
            GUICtrlSetState($iButton1, $GUI_FOCUS)
          Else
            ControlSend ($hGUI2, "", "", "^{TAB}")
          EndIf
      EndSwitch
  EndSwitch
WEnd

 

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