Page 1 of 2 12>
Topic Options
#90886 - 2003-01-10 08:28 AM Protect ListView temporary from new sort
Jens Offline
Fresh Scripter

Registered: 2001-06-25
Posts: 19
Loc: Kiel ( Germany )
Hallo.

After select an Item from ListView the Script makes some operations and then it changes the ListView in
order to visualisize the result. For this im using $Item.Index.
During Script aktion it is possible to sort the ListView new and then $Item.Index is wrong.
How can I protect the ListView temporary from new sort.
I have tryed BeginUpdate/EndUpdate, but it will only disable the rendering - sort is possible.

Thanks for your help.
Jens

Top
#90887 - 2003-01-10 08:40 AM Re: Protect ListView temporary from new sort
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Jens,

Have you tried to set .HeaderStyle temporary to 2 (IIRC it is the value for No Sort )

hth

J.

[ 10. January 2003, 08:43: Message edited by: jpols ]
_________________________



Top
#90888 - 2003-01-10 09:09 AM Re: Protect ListView temporary from new sort
Jens Offline
Fresh Scripter

Registered: 2001-06-25
Posts: 19
Loc: Kiel ( Germany )
Thanks for the fast help.

Temporary set .HeaderStyle=1 and reset after changings to .HeaderStyle=2 is working fine.

Can you explain me IIRC value ?

Jens

Top
#90889 - 2003-01-10 09:44 AM Re: Protect ListView temporary from new sort
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
IIRC is short for "If I Recall Correctly" [Wink]
_________________________



Top
#90890 - 2003-01-10 09:59 AM Re: Protect ListView temporary from new sort
Jens Offline
Fresh Scripter

Registered: 2001-06-25
Posts: 19
Loc: Kiel ( Germany )
That's a good question. But I think to use the
Index is easier and faster then comparing all
Items in a very large List. :-)

Top
#90891 - 2003-01-10 10:02 AM Re: Protect ListView temporary from new sort
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
So now I starting to fail following you [Eek!]

What exactly should the ListView behave please post a script snippet of what you have !
_________________________



Top
#90892 - 2003-01-10 11:07 AM Re: Protect ListView temporary from new sort
Jens Offline
Fresh Scripter

Registered: 2001-06-25
Posts: 19
Loc: Kiel ( Germany )
It is a Script to change DHCP Server entries and
handle the reservations. For security reasons only a small range of IP's has access to the internet.
The ListView shows a just in time dumped DHCP entries list. After selecting an Item you can open or close
the Access.
In order to save the time for dumping and realoading the hole list from the DHCP Server again the script
has to update the ListView entries too.

code:
; created by Jens Ludolph 2002
; changed by Jens Ludolph 10.01.03
; Version KiXtart 2001.412
;========================================
Break ON
;========================================
$Path="D:\IPtoDHCP\"
$closeAccess=0
$LabelBackColor=&C9C9C9
;----------------------------------------
; FormDefinition
;----------------------------------------
$Title=" DHCP Konfiguration"
;----------------------------------------
$Form = CreateObject("Kixtart.Form")
$Form.Caption = $Title
$Form.Size = 620,418
$form.fontname = "Arial"
$form.fontsize = 9
$form.fontbold = 0
$form.forecolor = &808080
;----------------------------------------
; ListDefinition
;----------------------------------------
$XCoo=20
$YCoo=70
$ListView = $Form.ListView
$ListView.Location = $XCoo,$YCoo
$ListView.Size = 350, 216
$ListView.FullRowSelect = True
$ListView.OnClick = "fn_collect()"
$ListView.Sorted = 1
$ListView.MultiSelect = False
;$ListView.GridLines = True
$ListView.Columns.Count = 3
$ListView.Columns(0).Text = "Name"
$ListView.Columns(0).Width = 110
$ListView.Columns(1).Text = "IP-Address"
$ListView.Columns(1).Width = 110
$ListView.Columns(2).Text = "Mac-Address"
$ListView.Columns(2).Width = 110
;----------------------------------------
$prgProgressBar = $Form.ProgressBar("",$XCoo-10,$YCoo-30+320,380,20)
$prgProgressBar.Style = 1
$prgProgressBar.ForeColor =&808080
;----------------------------------------
; FrameDefinition
;----------------------------------------
$DHCP_Frame=$Form.Frame("DHCP Server List")
$DHCP_Frame.Location = $XCoo-10,$YCoo-30
$DHCP_Frame.Size = 380, 290
$Inte_Frame=$Form.Frame("Internet Address")
$Inte_Frame.Location = 400,$YCoo-30
$Inte_Frame.Size = 200, 140
$Pool_Frame=$Form.Frame("Pool Address")
$Pool_Frame.Location = 400,$YCoo+120
$Pool_Frame.Size = 200, 140
;----------------------------------------
; LabelDefinition
;----------------------------------------
$lbl_internet_na=$form.label("",460,$YCoo,110,18)
$lbl_internet_na.backcolor=$LabelBackColor
$lbl_internet_na.fontsize = 9
$lbl_internet_na.borderstyle = 5
$form.printxy(410,$YCoo-30+30,"Name :")
;----------------------------------------
$lbl_internet_ip=$form.label("",460,$YCoo+18+5,110,18)
$lbl_internet_ip.backcolor=$LabelBackColor
$lbl_internet_ip.fontsize = 9
$lbl_internet_ip.borderstyle = 5
$form.printxy(433,$YCoo-30+30+18+5,"IP :")
;----------------------------------------
$lbl_internet_ma=$form.label("",460,$YCoo+18+5+18+5,110,18)
$lbl_internet_ma.backcolor=$LabelBackColor
$lbl_internet_ma.fontsize = 9
$lbl_internet_ma.borderstyle = 5
$form.printxy(422,$YCoo-30+30+18+5+18+5,"Mac :")
;----------------------------------------
$lbl_pool_na=$form.label("",460,$YCoo+150,110,18)
$lbl_pool_na.backcolor=$LabelBackColor
$lbl_pool_na.fontsize = 9
$lbl_pool_na.borderstyle = 5
$form.printxy(410,$YCoo+150,"Name :")
;----------------------------------------
$lbl_pool_ip=$form.label("",460,$YCoo+150+18+5,110,18)
$lbl_pool_ip.backcolor=$LabelBackColor
$lbl_pool_ip.fontsize = 9
$lbl_pool_ip.borderstyle = 5
$form.printxy(433,$YCoo+150+18+5,"IP :")
;----------------------------------------
$lbl_pool_ma=$form.label("",460,$YCoo+150+18+5+18+5,110,18)
$lbl_pool_ma.backcolor=$LabelBackColor
$lbl_pool_ma.fontsize = 9
$lbl_pool_ma.borderstyle = 5
$form.printxy(422,$YCoo+150+18+5+18+5,"Mac :")
;----------------------------------------
; ButtomDefinition
;----------------------------------------
$Bt_Exit = $Form.Button
$Bt_Exit.Location = $Form.ClientWidth-10-75,$Form.ClientHeight-10-23
$Bt_Exit.Size = 75,23
$Bt_Exit.Text = "Exit"
$Bt_Exit.OnCLick = "Quit()"
;----------------------------------------
$Bt_Neu = $Form.Button
$Bt_Neu.Location = $Form.ClientWidth-10-75-10-75,$Form.ClientHeight-10-23
$Bt_Neu.Size = 75,23
$Bt_Neu.Text = "New"
$Bt_Neu.OnCLick = "fn_bt_neueAuswahl()"
;----------------------------------------
$Bt_Scope1 = $Form.Button
$Bt_Scope1.Location = $XCoo+15,$YCoo-30+$DHCP_Frame.ClientHeight-10-23
$Bt_Scope1.Size = 100,23
$Bt_Scope1.Text = "Location1"
$Bt_Scope1.OnCLick = "fn_bt_Scope1()"
;----------------------------------------
$Bt_Scope2 = $Form.Button
$Bt_Scope2.Location = $XCoo+15+100+10,$YCoo-30+$DHCP_Frame.ClientHeight-10-23
$Bt_Scope2.Size = 100,23
$Bt_Scope2.Text = "Location2"
$Bt_Scope2.OnCLick = "fn_bt_Scope2()"
;----------------------------------------
$Bt_Scope3 = $Form.Button
$Bt_Scope3.Location = $XCoo+15+100+10+100+10,$YCoo-30+$DHCP_Frame.ClientHeight-10-23
$Bt_Scope3.Size = 100,23
$Bt_Scope3.Text = "Location3"
$Bt_Scope3.OnCLick = "fn_bt_Scope3()"
;----------------------------------------
$Bt_closeAccess = $Form.Button
$Bt_closeAccess.Location = 465,$YCoo+75
$Bt_closeAccess.Size = 100,23
$Bt_closeAccess.Text = "Close Access"
$Bt_closeAccess.OnCLick = "fn_bt_closeAccess()"
;----------------------------------------
$Bt_openAccess = $Form.Button
$Bt_openAccess.Location = 465,$YCoo+150+75
$Bt_openAccess.Size = 100,23
$Bt_openAccess.Text = "Open Access"
$Bt_openAccess.OnCLick = "fn_bt_openAccess()"
$Bt_closeAccess.Enabled = False
$Bt_openAccess.Enabled = False
;----------------------------------------
;$Form.TopMost=True
$Form.Visible=True
$Form.Center
$Form.Show

fn_Label("Please select scope",&008040)

While $Form.Visible
$=Execute($Form.DoEvents)
Loop
;----------------------------------------
; FunctionDefinition
;----------------------------------------
Function fn_ListCreate()
;----------------------------------------
$J=0
$RowIndex=0
$draw_end=0
$ListView.HeaderStyle=1
$ListView.Items.clear
$draw_entry=0
$draw_end=10
$ProgressPrompt = "Export DHCP data from " + $ServerIP
fn_Draw_State($draw_entry, $draw_end, 0.03)
SHELL "%COMSPEC% /C " + $Path + "DHCPCMD.exe " + $ServerIP + " enumclients " + $ScopeIP + " -h >" + $Path + $Location+ ".txt"
If Open (10, $path + $Location + ".txt", 2) = 0
$TempDHCPList = ''
$LineDHCPList = ReadLine (10)
While @error = 0
If $LineDHCPList<>"DHCP Server version 4.1" AND $LineDHCPList<>"Command successfully completed." AND Len($LineDHCPList)<53 AND INSTR($LineDHCPList,"(null)")=0
$TempDHCPList = $TempDHCPList + $LineDHCPList + ','
EndIf
$LineDHCPList = ReadLine (10)
Loop
Close (10)
$ArrayDHCPList = Split (SubStr ($TempDHCPList, 1, Len ($TempDHCPList) - 1), ',', -1)
$ListView.Items.Count = Val(UBound ($ArrayDHCPList)+1)
$ProgressPrompt = "Input DHCP data"
FOR $Index = 0 TO Val(UBound ($ArrayDHCPList))
if Val(UBound ($ArrayDHCPList))<=90
$draw_entry=$draw_end
$draw_end=$draw_entry+(90/Val(UBound ($ArrayDHCPList)))
fn_Draw_State($draw_entry, $draw_end, 0.03)
else
if $J=(Val(UBound ($ArrayDHCPList))/90)+1
$draw_entry=$draw_end
$draw_end=$draw_entry+1
fn_Draw_State($draw_entry, $draw_end, 0.03)
$J=0
endif
endif

for $m=len($ArrayDHCPList[$Index]) to 1 Step -1
if SUBSTR($ArrayDHCPList[$Index],$m-1,1)=" "
$MacAd=SUBSTR($ArrayDHCPList[$Index],$m,len($ArrayDHCPList[$Index]))
$ListView.Items($RowIndex).SubItems(2).Text = $MacAd
$ArpIn=RTRIM(SUBSTR($ArrayDHCPList[$Index],1,$m-1))
goto "enum_name"
endif
next
:enum_name
for $m=len($ArpIn) to 1 Step -1
if SUBSTR($ArpIn,$m-1,1)=" "
$Name=SUBSTR($ArpIn,$m,len($ArpIn))
if $Name="(null)"
$RowIndex=$RowIndex-1
goto "enum_fin"
endif
$ListView.Items($RowIndex).SubItems(0).Text = $Name
$ArpIn=RTRIM(SUBSTR($ArpIn,1,$m-1))
goto "enum_ip"
endif
next
:enum_ip
for $m=len($ArpIn) to 1 Step -1
if SUBSTR($ArpIn,$m-1,1)=" "
$IPBase=SUBSTR($ArpIn,$m,len($ArpIn))
$ListView.Items($RowIndex).SubItems(1).Text = $IPBase
goto "enum_fin"
endif
next
:enum_fin
$RowIndex=$RowIndex+1
$J=$J+1
NEXT
fn_Draw_State($draw_end, 100, 0.03)
fn_Draw_State(0,0,0.03)
fn_Label("Select from list",&008040)
ENDIF
$ListView.HeaderStyle=2
EndFunction
;----------------------------------------
Function fn_collect()
;----------------------------------------
$ListView.HeaderStyle=1
DIM $IPPart[10]
$found=0
$red_inter=0
$green_inter=0
$green_pool=0
$J=0
$draw_end=0
$ProgressPrompt = "Checking selection"
if $lbl_internet_na.caption=$lbl_pool_na.caption
fn_clearLabel()
endif
For Each $Item in $ListView.SelectedItems
$Name_sel=$Item.SubItems(0).Text
$IPBase_sel=$Item.SubItems(1).Text
$MacAd_sel=$Item.SubItems(2).Text
$SelInd=$Item.Index
Next
$I=1
$SP=SPLIT($IPBase_sel,".")
For Each $Element In $SP
$IPPart[$I]=ltrim($Element)
$I=$I+1
Next
select
case VAL($IPPart[3])=XXX or VAL($IPPart[3])=YYY or (VAL($IPPart[3]+$IPPart[4])<=ZZZZZZ And $Location="Location2") or (VAL($IPPart[3]+$IPPart[4])<=10161 And $Location="Location3")
For $Index=0 to $RowIndex-1
fn_create_draw($draw_entry,$RowIndex,$J)
if $Name_sel=$ListView.Items($Index).SubItems(0).Text And $Index<>$SelInd
fn_red_pool($ListView.Items($Index).SubItems(0).Text,$ListView.Items($Index).SubItems(1).Text,$ListView.Items($Index).SubItems(2).Text)
$SelInd_pool=$Index
else
if INSTR($Name_sel,"FREE")
if $green_inter=0
fn_green_inter($Name_sel,$IPBase_sel,$MacAd_sel)
endif
$SelInd_internet=$SelInd
goto "end_fn_collect"
else
if $red_inter=0
fn_red_inter($Name_sel,$IPBase_sel,$MacAd_sel)
endif
$SelInd_internet=$SelInd
endif
endif
$J=$J+1
Next
case VAL($IPPart[3])<>XXX or VAL($IPPart[3])<>YYY or (VAL($IPPart[3]+$IPPart[4])>ZZZZZZ And $Location="Location2") or (VAL($IPPart[3]+$IPPart[4])>10161 And $Location="Location3")
For $Index=0 to $RowIndex-1
fn_create_draw($draw_entry,$RowIndex,$J)
if $Name_sel=$ListView.Items($Index).SubItems(0).Text And $Index<>$SelInd
fn_red_inter($ListView.Items($Index).SubItems(0).Text,$ListView.Items($Index).SubItems(1).Text,$ListView.Items($Index).SubItems(2).Text)
fn_red_pool($Name_sel,$IPBase_sel,$MacAd_sel)
$found=1
$SelInd_internet=$Index
else
if $found=0
if $green_pool=0
fn_green_pool($Name_sel,$IPBase_sel,$MacAd_sel)
endif
endif
$SelInd_pool=$SelInd
endif
$J=$J+1
Next
endselect
:end_fn_collect
fn_Draw_State($draw_end, 100, 0.01)
fn_Draw_State(0,0,0.01)
if $lbl_internet_na.caption="" or INSTR($lbl_internet_na.caption,"FREE")<>0
$Bt_closeAccess.Enabled = False
else
$Bt_closeAccess.Enabled = True
endif
if $lbl_pool_na.caption<>"" And $lbl_internet_na.caption<>""
$Bt_openAccess.Enabled = True
else
$Bt_openAccess.Enabled = False
endif
if (INSTR($Name_sel,"FREE")=1 and $lbl_pool_na.caption="") or $lbl_internet_na.caption=""
fn_Label("Select from list",&008040)
else
fn_Label("Select from list or action button",&008040)
endif
$ListView.HeaderStyle=2
EndFunction
;----------------------------------------
Function fn_dhcp_change($fnCaller)
;----------------------------------------
$ListView.HeaderStyle=1
$DelStr=$Path+"DHCPCMD.exe " + $ServerIP + " removereservedip " + $ScopeIP + " " + ltrim($lbl_internet_ip.caption) + " " + ltrim($lbl_internet_ma.caption)
$AddStr=$Path+"DHCPCMD.exe " + $ServerIP + " addreservedip " + $ScopeIP + " " + $IPNew + " " + $MacNew + " " + $NameNew
if $fnCaller=1
fn_Label("closing access for " + ltrim($lbl_internet_na.caption),&808080)
fn_close($DelStr)
$ProgressPrompt="closing access for " + ltrim($lbl_internet_na.caption)
fn_Draw_State(0, 100, 0.03)
fn_Draw_State(0, 0, 0.03)
fn_Label("protecting IP " + ltrim($lbl_internet_ip.caption),&808080)
fn_open($AddStr)
$ProgressPrompt="protecting IP " + ltrim($lbl_internet_ip.caption)
fn_Draw_State(0, 100, 0.03)
fn_Draw_State(0, 0, 0.03)
fn_Label("close Access finished",&808080)
$status="close Access finished"
Sleep 1
else
fn_Label("preaparing access for " + ltrim($lbl_pool_na.caption),&808080)
fn_close($DelStr)
$ProgressPrompt="preaparing access for " + ltrim($lbl_pool_na.caption)
fn_Draw_State(0, 100, 0.03)
fn_Draw_State(0, 0, 0.03)
fn_Label("openinging IP " + ltrim($lbl_internet_ip.caption),&808080)
fn_open($AddStr)
$ProgressPrompt="openinging IP " + ltrim($lbl_internet_ip.caption)
fn_Draw_State(0, 100, 0.03)
fn_Draw_State(0, 0, 0.03)
fn_clearLabel_pool()
fn_Label("open Access finished",&808080)
$status="open Access finished"
Sleep 1
endif
if $lbl_pool_na.caption=""
fn_Label("Select from list",&008040)
else
fn_Label("Select from list or action button",&008040)
endif
fn_writeLog($DelStr, $AddStr, $status)
$fnCaller=0
$ListView.HeaderStyle=2
EndFunction
;----------------------------------------
Function fn_close($DelStr)
;----------------------------------------
; $nul=messagebox("%COMSPEC% /C " + $DelStr + " >NUL:","ok",0)
SHELL "%COMSPEC% /C " + $DelStr + " >NUL:"
EndFunction
;----------------------------------------
Function fn_open($AddStr)
;----------------------------------------
; $nul=messagebox("%COMSPEC% /C " + $AddStr + " >NUL:","ok",0)
SHELL "%COMSPEC% /C " + $AddStr + " >NUL:"
fn_green_inter($NameNew,$IPNew,$MacNew)
EndFunction
;----------------------------------------
Function fn_writeLog($DelStr, $AddStr, $status)
;----------------------------------------
$nul=open(8, $path + "DHCPkonf.log", 5)
$nul=writeline(8, "====================================================" + Chr(13)+ Chr(10))
$nul=writeline(8, @Date + " " + @Time + Chr(13)+ Chr(10))
$nul=writeline(8, "====================================================" + Chr(13)+ Chr(10))
$nul=writeline(8, $DelStr + Chr(13)+ Chr(10))
$nul=writeline(8, $AddStr + Chr(13)+ Chr(10))
$nul=writeline(8, $status + Chr(13)+ Chr(10))
$nul=writeline(8, @fullname + Chr(13)+ Chr(10))
$nul=close (8)
EndFunction
;----------------------------------------
Function fn_red_inter($Name_sel,$IPBase_sel,$MacAd_sel)
;----------------------------------------
$red_inter=1
$lbl_internet_na.backcolor=&786FD2
$lbl_internet_na.caption=" "+Ltrim($Name_sel)
$lbl_internet_ip.backcolor=&786FD2
$lbl_internet_ip.caption=" "+Ltrim($IPBase_sel)
$lbl_internet_ma.backcolor=&786FD2
$lbl_internet_ma.caption=" "+Ltrim($MacAd_sel)
EndFunction
;----------------------------------------
Function fn_green_inter($Name_sel,$IPBase_sel,$MacAd_sel)
;----------------------------------------
$green_inter=1
$lbl_internet_na.backcolor=&65CDA0
$lbl_internet_na.caption=" "+Ltrim($Name_sel)
$lbl_internet_ip.backcolor=&65CDA0
$lbl_internet_ip.caption=" "+Ltrim($IPBase_sel)
$lbl_internet_ma.backcolor=&65CDA0
$lbl_internet_ma.caption=" "+Ltrim($MacAd_sel)
EndFunction
;----------------------------------------
Function fn_red_pool($Name_sel,$IPBase_sel,$MacAd_sel)
;----------------------------------------
$lbl_pool_na.backcolor=&65CDA0
$lbl_pool_na.caption=" "+Ltrim($Name_sel)
$lbl_pool_ip.backcolor=&786FD2
$lbl_pool_ip.caption=" "+Ltrim($IPBase_sel)
$lbl_pool_ma.backcolor=&786FD2
$lbl_pool_ma.caption=" "+Ltrim($MacAd_sel)
EndFunction
;----------------------------------------
Function fn_green_pool($Name_sel,$IPBase_sel,$MacAd_sel)
;----------------------------------------
$green_pool=1
$lbl_pool_na.backcolor=&65CDA0
$lbl_pool_na.caption=" "+Ltrim($Name_sel)
$lbl_pool_ip.backcolor=&65CDA0
$lbl_pool_ip.caption=" "+Ltrim($IPBase_sel)
$lbl_pool_ma.backcolor=&65CDA0
$lbl_pool_ma.caption=" "+Ltrim($MacAd_sel)
EndFunction
;----------------------------------------
Function fn_clearLabel()
;----------------------------------------
$lbl_internet_na.backcolor=$LabelBackColor
$lbl_internet_na.caption=""
$lbl_internet_ip.backcolor=$LabelBackColor
$lbl_internet_ip.caption=""
$lbl_internet_ma.backcolor=$LabelBackColor
$lbl_internet_ma.caption=""
$lbl_pool_na.backcolor=$LabelBackColor
$lbl_pool_na.caption=""
$lbl_pool_ip.backcolor=$LabelBackColor
$lbl_pool_ip.caption=""
$lbl_pool_ma.backcolor=$LabelBackColor
$lbl_pool_ma.caption=""
$Bt_closeAccess.Enabled = False
$Bt_openAccess.Enabled = False
EndFunction
;----------------------------------------
Function fn_clearLabel_pool()
;----------------------------------------
$lbl_pool_na.backcolor=$LabelBackColor
$lbl_pool_na.caption=""
$lbl_pool_ip.backcolor=$LabelBackColor
$lbl_pool_ip.caption=""
$lbl_pool_ma.backcolor=$LabelBackColor
$lbl_pool_ma.caption=""
$Bt_openAccess.Enabled = False
EndFunction
;----------------------------------------
Function fn_bt_closeAccess()
;----------------------------------------
$Bt_closeAccess.Enabled = False
$closeAccess=1
DIM $IPPart[10]
$IPDel=$lbl_internet_ip.caption
$I=1
$SP=SPLIT($IPDel,".")
For Each $Element In $SP
$IPPart[$I]=ltrim($Element)
$I=$I+1
Next
select
case len($IPPart[4])=3
$IPPart[4]=$IPPart[4]
case len($IPPart[4])=2
$IPPart[4]="0" + $IPPart[4]
case len($IPPart[4])=1
$IPPart[4]="00" + $IPPart[4]
endselect
$NameNew="FREE" + substr($IPPart[3],len($IPPart[3]),1) + $IPPart[4]
$MacNew="abcdef00" + substr($IPPart[3],len($IPPart[3]),1) + $IPPart[4]
$IPNew=ltrim($lbl_internet_ip.caption)
fn_dhcp_change($closeAccess)
$ListView.Items($SelInd_internet).SubItems(0).Text = $NameNew
$ListView.Items($SelInd_internet).SubItems(2).Text = $MacNew
EndFunction
;----------------------------------------
Function fn_bt_openAccess()
;----------------------------------------
$Bt_openAccess.Enabled = False
$closeAccess=0
$NameNew=ltrim($lbl_pool_na.caption)
$MacNew=ltrim($lbl_pool_ma.caption)
$IPNew=ltrim($lbl_internet_ip.caption)
fn_dhcp_change($closeAccess)
$ListView.Items($SelInd_internet).SubItems(0).Text = $NameNew
$ListView.Items($SelInd_internet).SubItems(2).Text = $MacNew
$ListView.Items($SelInd_pool).SubItems(0).Text = "cleared"
$ListView.Items($SelInd_pool).SubItems(1).Text = "cleared"
$ListView.Items($SelInd_pool).SubItems(2).Text = "cleared"
EndFunction
;----------------------------------------
Function fn_bt_Scope1()
;----------------------------------------
$DHCP_Frame.Caption="Scope 1"
$Bt_Scope1.Enabled = False
$Bt_Scope2.Enabled = False
$Bt_Scope3.Enabled = False
$ServerIP="AAA.AAA.AAA.AAA"
$ScopeIP="BBB.BBB.BBB.BBB"
; $Location="test"
$Location="Location1"
fn_ListCreate()
EndFunction
;----------------------------------------
Function fn_bt_Scope2()
;----------------------------------------
$DHCP_Frame.Caption="Scope 2"
$Bt_Scope1.Enabled = False
$Bt_Scope2.Enabled = False
$Bt_Scope3.Enabled = False
$ServerIP="CCC.CCC.CCC.CCC"
$ScopeIP="DDD.DDD.DDD.DDD"
$Location="Location2"
fn_ListCreate()
EndFunction
;----------------------------------------
Function fn_bt_Scope3()
;----------------------------------------
$DHCP_Frame.Caption="Scope 3"
$Bt_Scope1.Enabled = False
$Bt_Scope2.Enabled = False
$Bt_Scope3.Enabled = False
$ServerIP="EEE.EEE.EEE.EEE"
$ScopeIP="FFF.FFF.FFF.FFF"
$Location="Location3"
fn_ListCreate()
EndFunction
;----------------------------------------
Function fn_bt_neueAuswahl()
;----------------------------------------
$ListView.Items.clear
fn_clearLabel()
$Bt_closeAccess.Enabled = False
$Bt_openAccess.Enabled = False
$Bt_Scope1.Enabled = True
$Bt_Scope2.Enabled = True
$Bt_Scope3.Enabled = True
fn_Label("Please select scope",&008040)
EndFunction
;----------------------------------------
Function fn_Draw_State($draw_entry, $draw_end, $SleepTime)
;----------------------------------------
$XCordinate=($XCoo-10+380)/2-(( Len ( $ProgressPrompt ) *4 )/2)
$lbl_progresspompt=$form.label($ProgressPrompt,$XCordinate,$YCoo-30+300,( Len ( $ProgressPrompt ) *6 )+20,20)
$lbl_progresspompt.fontsize = 8
$lbl_progresspompt.forecolor = &808080
For $lProgress = $draw_entry to $draw_end
$prgProgressBar.Value = $lProgress
Sleep $SleepTime
Next
EndFunction
;----------------------------------------
Function fn_Label($ProgressPrompt,$PromptColor)
;----------------------------------------
$XCordinate=($XCoo-10+380)/2-(( Len ( $ProgressPrompt ) *4 )/2)
$lbl_progresspompt=$form.label($ProgressPrompt,$XCordinate,$YCoo-30+300,( Len ( $ProgressPrompt ) *5 )+20,20)
$lbl_progresspompt.fontsize = 8
$lbl_progresspompt.forecolor = $PromptColor
EndFunction
;----------------------------------------
Function fn_create_draw($draw_entry,$RowIndex,$J)
;----------------------------------------
if ($RowIndex-1)<=100
$draw_entry=$draw_end
$draw_end=$draw_entry+(100/Val($RowIndex-1))
fn_Draw_State($draw_entry, $draw_end, 0.01)
else
if $J=(Val($RowIndex-1)/100)+1
$draw_entry=$draw_end
$draw_end=$draw_entry+1
fn_Draw_State($draw_entry, $draw_end, 0.01)
$J=0
endif
endif
EndFunction

Exit 1


Top
#90893 - 2003-01-10 11:27 AM Re: Protect ListView temporary from new sort
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Ok,

got the script ... form looks very professional !
Please give me a while to get into the code [Wink]

So if I understand that correctly you want the ListView to sort automatically after update ?

Jochen
_________________________



Top
#90894 - 2003-01-10 11:32 AM Re: Protect ListView temporary from new sort
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
If this is the case ... try playing with the ListView.Sorted property ;

Not sure what build of kixforms you work with , but with the current released (36) it should work ...
(I personally have a copy of build 37 (Pre-Release)=
maybe something like:

code:
$ListView.Sorted = 1 ;???

_________________________



Top
#90895 - 2003-01-10 11:38 AM Re: Protect ListView temporary from new sort
Jens Offline
Fresh Scripter

Registered: 2001-06-25
Posts: 19
Loc: Kiel ( Germany )
No, automatically sort after update ... only view the changings on DHCP Server without reloading the hole List from it ... Jochen, it's working very well. The tip to change .HeaderStyle has solve my problem and I have posted the script, because you have asked for it.

Thank you for your help, again.

Top
#90896 - 2003-01-11 12:06 AM Re: Protect ListView temporary from new sort
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Jens,

that is nice to hear , just one more tip (The first thing i realized to be improved) :

Try filling the ListView with life (Cells) after you evaluated the values for it , reason:

The OnClick event for the View fires it's function in the current version even if the cells are empty ...

Jochen
_________________________



Top
#90897 - 2003-01-10 01:10 PM Re: Protect ListView temporary from new sort
Jens Offline
Fresh Scripter

Registered: 2001-06-25
Posts: 19
Loc: Kiel ( Germany )
... the script looks professional ... [Wink] , but I am far away to be a profi [Smile] .

Do you mean that I should define the OnClick Event after unktion fn_ListCreate() ?

Jens

Top
#90898 - 2003-01-10 01:20 PM Re: Protect ListView temporary from new sort
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
back from lunch,

no, the values and so the row amount seems to be dynamic ... best way to handle this is in my opinion to check the cell value not being empty On Click event [Wink]
_________________________



Top
#90899 - 2003-01-10 01:21 PM Re: Protect ListView temporary from new sort
Jens Offline
Fresh Scripter

Registered: 2001-06-25
Posts: 19
Loc: Kiel ( Germany )
... Yes, you mean. I have made a test. Thanks - I have not thought about the possibility to make a click into an emty List [Smile]

Regards
Jens

Top
#90900 - 2003-01-10 01:25 PM Re: Protect ListView temporary from new sort
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
no i meant no ...

just let the fn_collect() function check whether the clicked row has a value
( "if not SelectedItem.Value exit endif)

[ 10. January 2003, 13:26: Message edited by: jpols ]
_________________________



Top
#90901 - 2003-01-10 01:51 PM Re: Protect ListView temporary from new sort
Jens Offline
Fresh Scripter

Registered: 2001-06-25
Posts: 19
Loc: Kiel ( Germany )
Yeah ... same result, but seams to be the better way.
Thanks ...
[Confused] Can't receive any Value by using $SelectedItem.Value ??? What's wrong ?

Top
#90902 - 2003-01-10 01:56 PM Re: Protect ListView temporary from new sort
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
was just a sample , no valid code, Sorry !!! [Frown]

try:
code:
;function start 
if $ListView.FocusedItem.SubItems(0).text ;selection has a value in first cell -> collect data

;code here

endif
;function end

_________________________



Top
#90903 - 2003-01-10 02:09 PM Re: Protect ListView temporary from new sort
Jens Offline
Fresh Scripter

Registered: 2001-06-25
Posts: 19
Loc: Kiel ( Germany )
It's working !!!
What's your opinion to this script ?

Jens
Thank you and have a nice weekend.

Top
#90904 - 2003-01-10 02:17 PM Re: Protect ListView temporary from new sort
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
I must say that I really like the form ... really like to see it working (the DHCP Servers need to be selectable , no ?)
_________________________



Top
#90905 - 2003-01-10 05:19 PM Re: Protect ListView temporary from new sort
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I've seen two examples of very professional looking windows script in as many weeks (the first was rad's mm script). This script is extremely well done.
Top
Page 1 of 2 12>


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 569 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.074 seconds in which 0.026 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org