Jump to content

IpAddress_Create gui on a tab?


Recommended Posts

When you create control on the Tab by UDF function (_GUICtrlCreate) and not by internal AutoIt's function (GUICtrlCreate) you must show/hide this control yourself.

#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <IPAddressConstants.au3>
#include <TabConstants.au3>
#include <GuiIPAddress.au3>
#include <GuiTab.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 593, 453, 193, 115)
$Tab1 = GUICtrlCreateTab(16, 24, 521, 385)
$hTab = GUICtrlGetHandle($Tab1)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$IPAddress1 = _GUICtrlIpAddress_Create($Form1, 56, 112, 130, 21)
_GUICtrlIpAddress_Set($IPAddress1, "0.0.0.0")
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$MyButton1 = GUICtrlCreateButton("MyButton1", 104, 120, 100, 30, 0)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTab, $fValid
    $hWndTab = $hTab

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndTab
            Switch $iCode
                Case $TCN_SELCHANGE
                    If _GUICtrlTab_GetCurSel($hTab) = 0 Then ; zero based index of current selected TabItem
                        _GUICtrlIpAddress_ShowHide ($IPAddress1, @SW_SHOW)
                    Else
                        _GUICtrlIpAddress_ShowHide ($IPAddress1, @SW_HIDE)
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Core of solution is to catch $TCN_SELCHANGE notification - when selection changes and show/hide what you want.

Here is original post by Gary which I used as start for my example.

http://www.autoitscript.com/forum/index.ph...st&p=421134

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