Jump to content

Problem with _GUICtrlIpAddress_Create


vickerps
 Share

Recommended Posts

Hi Guys

Im trying to create a script that allow someone to enter a number of ip adresses.

when i use _GUICtrlIpAddress_Create on the 17th address the box disappears from the sub form.

Anyone tell me why this is?

;Include Functions
#Include <GuiIPAddress.au3>
#INCLUDE <GUIConstants.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <ListviewConstants.au3>
Global $Avarray[30],$I_IP
$BMP = @ScriptDir & "\BackGround.bmp"
$TextColour = "0x000000"
$POSTotal = 20
$n=1
Opt("GUICoordMode",1)
$F = GuiCreate("Torex",@DesktopWidth,@DesktopHeight,0,0,$WS_SYSMENU,$WS_EX_TOPMOST)
GUICtrlCreatePic ($BMP,0,0,@DesktopWidth,@DesktopHeight)
GUICtrlSetState(-1,$GUI_DISABLE)

$E_Nodes_IPs = GUICtrlCreateListView("                      |                      ",60,210,295,450,$LVS_NOCOLUMNHEADER+$LVS_NOSORTHEADER)
  GUICtrlSetFont(-1,12)
  GUISetState(@SW_SHOW,$F)
   
  IF $n < $postotal Then
   Do
    Subform($n)
    $AVarray[$n] = GUICtrlCreateListViewItem($n & "|" & _GUICtrlIpAddress_Get($I_IP),$E_Nodes_IPs)
    ;$AVarray[$n] = GUICtrlCreateListViewItem("Till" & $n & "|" & GUICtrlRead($I_IP), $E_Nodes_IPs)
    $n = $n +1
   until $n > $POSTotal
  endif
Func Subform($x)
GUISetState(@SW_DISABLE,$F)

$SubF = GuiCreate("Manual Setup",400 ,200,500,230,$DS_CONTEXTHELP,$WS_EX_TOPMOST)
  GUICtrlCreatePic ($BMP,0,0,400,200)
   GUICtrlSetState(-1,$GUI_DISABLE)
  $Lbl_Message = GUICtrlCreateLabel($x ,10,10,390,20)
   GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
   GUICtrlSetFont(-1,12)
   GUICtrlSetColor (-1,$TextColour)
 
  $Lbl_IP = GUICtrlCreateLabel("IP address:",10,60,130,20)
   GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
   GUICtrlSetFont(-1,12)
   GUICtrlSetColor (-1,$TextColour)

  $I_IP = _GUICtrlIpAddress_Create ($SubF,140,60,110,20)
  ;$I_IP = GUICtrlCreateInput("",140,60,110,20)
   GUICtrlSetLimit(-1,15)
   GUICtrlSetFont(-1,10)

  $B_OK = GUICtrlCreateButton("&OK",300,137,90,35)

  GUISetState(@SW_SHOW,$SubF)
 
   While 1
    $Msg=GUIGetMsg()
  
    Switch $Msg
     Case $B_OK
       ExitLoop
    EndSwitch
   Wend
   
  GUISetState(@SW_HIDE,$SubF)
  GUISetState(@SW_ENABLE,$F)
ENdfunc
Link to comment
Share on other sites

It's because you're recreating the GUI for the sub form every time you loop through the Do loop. You should either move the GUI creation out of the function, or delete the GUI after the function finishes, or just don't use a separate GUI just to add an IP address control. Here's how to do it using GUIDelete and your code modified.

;Include Functions
#include <GuiIPAddress.au3>
#include <GUIConstants.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <ListviewConstants.au3>
Global $Avarray[30], $I_IP
Global $SubF
$BMP = @ScriptDir & "BackGround.bmp"
$TextColour = "0x000000"
$POSTotal = 20
$n = 1
Opt("GUICoordMode", 1)
$F = GUICreate("Torex", @DesktopWidth, @DesktopHeight, 0, 0, $WS_SYSMENU, $WS_EX_TOPMOST)
GUICtrlCreatePic($BMP, 0, 0, @DesktopWidth, @DesktopHeight)
GUICtrlSetState(-1, $GUI_DISABLE)
$E_Nodes_IPs = GUICtrlCreateListView("                    |                   ", 60, 210, 295, 450, $LVS_NOCOLUMNHEADER + $LVS_NOSORTHEADER)
GUICtrlSetFont(-1, 12)
GUISetState(@SW_SHOW, $F)
If $n < $POSTotal Then
    Do
        Subform($n)
        $Avarray[$n] = GUICtrlCreateListViewItem($n & "|" & _GUICtrlIpAddress_Get($I_IP), $E_Nodes_IPs)
        ;$AVarray[$n] = GUICtrlCreateListViewItem("Till" & $n & "|" & GUICtrlRead($I_IP), $E_Nodes_IPs)
        $n = $n + 1
        GUIDelete($SubF)
    Until $n > $POSTotal
EndIf
Func Subform($x)
    GUISetState(@SW_DISABLE, $F)
    $SubF = GUICreate("Manual Setup", 400, 200, 500, 230, $DS_CONTEXTHELP, $WS_EX_TOPMOST)
    GUICtrlCreatePic($BMP, 0, 0, 400, 200)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Lbl_Message = GUICtrlCreateLabel($x, 10, 10, 390, 20)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetFont(-1, 12)
    GUICtrlSetColor(-1, $TextColour)
    $Lbl_IP = GUICtrlCreateLabel("IP address:", 10, 60, 130, 20)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetFont(-1, 12)
    GUICtrlSetColor(-1, $TextColour)
    $I_IP = _GUICtrlIpAddress_Create($SubF, 140, 60, 110, 20)
    ;$I_IP = GUICtrlCreateInput("",140,60,110,20)
    GUICtrlSetLimit(-1, 15)
    GUICtrlSetFont(-1, 10)
    $B_OK = GUICtrlCreateButton("&OK", 300, 137, 90, 35)
    GUISetState(@SW_SHOW, $SubF)
    While 1
        $Msg = GUIGetMsg()
        Switch $Msg
            Case $B_OK
                ExitLoop
        EndSwitch
    WEnd
    GUISetState(@SW_ENABLE, $F)
EndFunc   ;==>Subform

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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