#91468 - 2003-02-16 07:59 PM
Re: KixForms - Typing inside ListView
|
Jochen
KiX Supporter
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
Krabourn,
I nearly forgot that I did something similar once in a subform regarding Highscores (The script is not published yet because of some missing functionality in kixforms regarding ImageLists)
Just hacked together the parts so that it will work ... The 3 columns there are a ListView (Data is stored in an ini file) as soon the actual score is below a HighScore for that specific level it lets you edit your name (A TextBox over the ListView SubItem) ... Maybe not exactly what you try but a start anyway ?
break on
$ini = @scriptdir + '\test.ini' $moves = 45 $Pieces = 9
$HS = 50,Anonymus,100,Anonymus,150,Anonymus
dim $highscore, $frmWin, $s, $txt, $pos, $top Global $item0, $item1, $item2
$frmWin = createobject("Kixtart.Form") $frmWin.Size = 250,135 $frmWin.Left = $frm.CLientWidth /2 - $frmWin.ClientWidth /2 $frmWin.Top = $frm.CLientHeight/2 - $frmWin.ClientHeight/2
$btnOK = $frmWin.Button("OK",$frmWin.ClientWidth/2+15,$frmWin.Clientheight-30,75,20) $btnOK.onclick = "$$frmWin.Hide"
$btnReset = $frmWin.Button("Reset Highscore",$frmWin.ClientWidth/2-90,$frmWin.Clientheight-30,90,20) $btnReset.onclick = "ResetHighScores(1)"
$lbl = $frmWin.Label("",140,5,100,15) $lbl.ForeColor = KiXtart
$lvw = $frmWin.ListView("",20,20,210,45) $lvw.enabled = 0 $lvw.View = 3 $lvw.BorderStyle = 0 $lvw.HeaderStyle = 0 $lvw.BackColor = $frmWin.BackColor $ = $lvw.Columns.add("",75,1) $ = $lvw.Columns.add("",45,1) $ = $lvw.Columns.add("",90,0) $item0 = $lvw.Items.Add("9 Pieces") $item1 = $lvw.Items.Add("16 Pieces") $item2 = $lvw.Items.Add("25 Pieces")
for $i = 0 to 4 step 2 $ = execute("$$item"+($i-$s)+".SubItems(1).Text = " + $HS[$i]) $ = execute("$$item"+($i-$s)+".SubItems(2).Text = " + $HS[$i+1]) $s = $s + 1 next
$highscore = CheckHighScore($moves,$Pieces) if $highscore $btnReset.Enabled = 0 $frmWin.Caption = "Highscore - $pieces Pieces" select case $Pieces = 9 $pos = 0 $top = 20 $HS[0] = $moves case $Pieces = 16 $pos = 1 $top = 35 $HS[2] = $moves case $Pieces = 25 $pos = 2 $top = 50 $HS[4] = $moves endselect $lbl.Caption = "Enter your name ..." $txtName = $frmWin.TextBox("",144,$top,100,18) $txtName.BorderStyle = 0 $txtName.BackColor = $frmWin.BackColor $txtName.OnLostFocus = "UpdateHighscores($$pieces)" $txtName.OnKeyDown = "if $$txtName.KeyCode=13 UpdateHighscores($$pieces) endif" $ = execute("$$item$pos.SubItems(1).Text = $$moves") $ = execute("$$item$pos.SubItems(2).Text = ''") $txtName.SetFocus else $frmWin.Caption = "Your Score : $moves moves" $btnOk.Default = 1 endif
$frmWin.Show while $frmWin.Visible $ = execute($frmWin.DoEvents)
function CheckHighScore($m,$p) select case $p = 9 and $m < $HS[0] $CheckHighScore = 1 case $p = 16 and $m < $HS[2] $CheckHighScore = 1 case $p = 25 and $m < $HS[4] $CheckHighScore = 1 endselect endfunction
function UpdateHighscores($p) dim $o $txtName.Hide select case $p = 9 $HS[1] = $txtName.Text $item0.SubItems(2).Text = $HS[1] case $p = 16 $HS[3] = $txtName.Text $item1.SubItems(2).Text = $HS[3] case $p = 25 $HS[5] = $txtName.Text $item2.SubItems(2).Text = $HS[5] endselect $o = join($HS,',') $ = writeprofilestring($ini,'Global','HighScores',$o) $btnReset.Enabled = 1 $btnOK.Default = 1 $lbl.Caption = "" endfunction
function ResetHighscores(optional $display) $ = writeprofilestring($ini,'Global','HighScores','50,Anonymus,100,Anonymus,150,Anonymus') $HS = split(readprofilestring($ini,'Global','HighScores'),',') for $i = 0 to ubound($HS) if not $HS[$i] $HS[$i] = "Anonymus" endif next if $display dim $s for $i = 0 to 4 step 2 $ = execute("$$item"+($i-$s)+".SubItems(1).Text = " + $HS[$i]) $ = execute("$$item"+($i-$s)+".SubItems(2).Text = " + $HS[$i+1]) $s = $s + 1 next endif endfunction
_________________________
|
Top
|
|
|
|
#91469 - 2003-02-16 09:43 PM
Re: KixForms - Typing inside ListView
|
krabourn
Hey THIS is FUN
Registered: 2000-12-11
Posts: 244
Loc: San Antonio, Texas, USA
|
I think I should share something, too. I share so often. That was sarcasm.
This is just a start a start of a generic DB/List editor. I am using it for adding/deleting/editing simple lists. This is my test script before I stick it into the real program. It supports my current needs, but I should add support for multiple columns.
http://www.geocities.com/krabourn@sbcglobal.net/
BREAK ON
$ScriptDir = @CurDir $iMargin = 5 $iLabelHeight = 15 $iButtonWidth = 86 $iButtonHeight = 30 $iButtonSmallWidth = 60 $iToolButtonWidth = 20 $iToolButtonHeight = 20 $FileRTAINI = $ScriptDir + '\RTA.INI' $aSMSTSMID = Split (ReadProfileString ($FileRTAINI, 'SMS', 'SMSTSMID'), ',', -1) $aSMSTSMName = Split (ReadProfileString ($FileRTAINI, 'SMS', 'SMSTSMNAME'), ',', -1) ;SMSTSMID=M5400634,M5400620,M5400621,M540061E,M540061F,M54005DE,M5400636,M5400635,M5400641, ;M5400637,M5400C85,M5400647,M5400638,M5400644,M5400643,M5400622,M54007F2,M54007F3 ;SMSTSMNAME=SAN - BB4738,SAN - BC5691,SAN - CB8564,SAN - CM9626,SAN - CR8337,SAN - DG4893, ;SAN - DS2616,SAN - EI3473,SAN - JH1579,SAN - JW9976,SAN - KR8770,SAN - RE4271,SAN - RP8192, ;SAN - RR7523,SAN - PT7845/JJ8313/MG7423,SAN - UNKNOWN,SAN - ISDN/RAS,SAN - SELF SUPPORT
;--- DB form $frmDB = CreateObject("Kixtart.Form") $frmDB.ClientWidth = 300 $frmDB.ClientHeight = 300 $frmDB.FontSize = 8 $frmDB.BorderStyle = 0 $frmDB.Center $frmDB.Rectangle(0, 0, $frmDB.ClientWidth, $frmDB.ClientHeight) $ilsicons = $frmDB.ImageList $ilsicons.ImageSize = 16,16 $ilsicons.Images.AddStrip($ScriptDir + '\RTA.bmp', &00FF00FF, 16, 16)
$txtDBName = $frmDB.TextBox $txtDBName.ToolTip = '' $txtDBName.Location = $iMargin, $iMargin $txtDBName.Size = 225, $iLabelHeight $txtDBName.BorderStyle = 5 $txtDBName.OnChange=' IF $$spnDBName.Visible = 0 AND $$txtDBName.Value <> "" $$btnDBAdd.Show ELSE $$btnDBAdd.Hide ENDIF' $txtDBName.OnGotFocus = '$$btnDBDelete.Hide'
$spnDBName = $frmDB.SpinButton $spnDBName.ToolTip = 'Which column to edit.' $spnDBName.Location = $txtDBName.Right + $iMargin, $txtDBName.Top $spnDBName.Size = 15,25 $spnDBName.Orientation = 0 $spnDBName.BorderStyle = 0 $spnDBName.OnChange = ' $$txtDBName.ToolTip = "" $$btnDBSave.ToolTip = "Save the Item back to the list." $$txtDBName.Text = $$lvwDB.Items($$lvwDBIndex).SubItems($$spnDBName.Value).Text $$txtDBName.SetFocus' $spnDBName.Hide
$btnDBSave = $frmDB.ToolButton $btnDBSave.ToolTip = 'Save the Item back to the list.' $btnDBSave.Size = $iToolButtonWidth, $iToolButtonHeight $btnDBSave.Location = $spnDBName.Right, $txtDBName.Top - 2 $btnDBSave.FlatStyle = 1 $btnDBSave.Alignment = 0 $btnDBSave.Icon = $ilsicons.Images(11) $btnDBSave.OnClick = ' IF $$spnDBName.Value = 0 $$lvwDB.Tag = 0 FOR $$Index = 0 TO $$lvwDB.Items.Count IF $$txtDBName.Text = $$lvwDB.Items($$Index).SubItems(0).Text $$Index = $$lvwDB.Items.Count + 1 $$txtDBName.ToolTip = "DUPLICATE" $$btnDBSave.ToolTip = "DUPLICATE - Save the Item back to the list." $$lvwDB.Tag = 1 ENDIF NEXT IF $$lvwDB.Tag = 0 $$lvwDB.Items($$lvwDBIndex).SubItems($$spnDBName.Value).Text = $$txtDBName.Text $$txtDBName.ToolTip = "" $$btnDBSave.ToolTip = "Save the Item back to the list." ENDIF $$lvwDB.Tag = "" ELSE $$lvwDB.Items($$lvwDBIndex).SubItems($$spnDBName.Value).Text = $$txtDBName.Text ENDIF $$txtDBName.SetFocus' $btnDBSave.Hide
$lvwDB = $frmDB.ListView $lvwDB.ToolTip = 'Double Click an item to edit.' $lvwDB.Location = $iMargin, $txtDBName.Bottom + $iMargin $lvwDB.Size = $frmDB.Width - (2 * $iMargin), $frmDB.Height - $lvwDB.Top - $iMargin $lvwDB.GridLines = 1 $lvwDB.View = 3 $lvwDB.FullRowSelect = 1 $lvwDB.OnDoubleClick = ' $$lvwDBIndex = $$lvwDB.FocusedItem.Index $$spnDBName.Value = $$spnDBName.Min $$txtDBName.Text = $$lvwDB.Items($$lvwDBIndex).SubItems($$spnDBName.Value).Text $$btnDBSave.Show $$spnDBName.Show $$txtDBName.SetFocus' $lvwDB.OnClick = ' $$lvwDBIndex = $$lvwDB.FocusedItem.Index $$txtDBName.Text = "" $$txtDBName.ToolTip = "" $$btnDBAdd.ToolTip = "Add to the list." $$btnDBSave.ToolTip = "Save the Item back to the list." $$btnDBSave.Hide $$spnDBName.Hide $$btnDBAdd.Hide $$btnDBDelete.Show' $lvwDBIndex = ''
$btnDBAdd = $frmDB.ToolButton $btnDBAdd.ToolTip = 'Add to the list.' $btnDBAdd.Size = $iToolButtonWidth, $iToolButtonHeight $btnDBAdd.Location = $txtDBName.Right + $iMargin, $txtDBName.Top - 2 $btnDBAdd.FlatStyle = 1 $btnDBAdd.Alignment = 0 $btnDBAdd.Icon = $ilsicons.Images(12) $btnDBAdd.Hide $btnDBAdd.OnClick = ' IF $$txtDBName.Text <> "" $$lvwDB.Tag = 0 FOR $$Index = 0 TO $$lvwDB.Items.Count IF $$txtDBName.Text = $$lvwDB.Items($$Index).SubItems(0).Text $$Index = $$lvwDB.Items.Count + 1 $$txtDBName.ToolTip = "DUPLICATE" $$btnDBAdd.ToolTip = "DUPLICATE - Add to the list." $$lvwDB.Tag = 1 ENDIF NEXT IF $$lvwDB.Tag = 0 $$Item = $$lvwDB.Items.Add($$txtDBName.Text) $$lvwDB.EnsureVisible($$Item.Index) $$lvwDBIndex = $$Item.Index $$spnDBName.Value = $$spnDBName.Min $$txtDBName.Text = $$lvwDB.Items($$Item.Index).SubItems($$spnDBName.Value).Text $$txtDBName.ToolTip = "" $$btnDBAdd.ToolTip = "Add to the list." $$btnDBSave.Show $$spnDBName.Show $$txtDBName.SetFocus ENDIF $$lvwDB.Tag = "" ENDIF $$txtDBName.SetFocus'
$btnDBDelete = $frmDB.ToolButton $btnDBDelete.ToolTip = 'Delete from the list.' $btnDBDelete.Size = $iToolButtonWidth, $iToolButtonHeight $btnDBDelete.Location = $txtDBName.Right + $iMargin, $txtDBName.Top - 2 $btnDBDelete.FlatStyle = 1 $btnDBDelete.Alignment = 0 $btnDBDelete.Icon = $ilsicons.Images(6) $btnDBDelete.Hide $btnDBDelete.OnClick = ' IF Val($$lvwDBIndex) >= 0 IF $$frmDB.MsgBox("Do you want to delete " + $$lvwDB.Items($$lvwDBIndex).SubItems(0).Text + "?", "Delete", 4) =&nbs p;6 $$lvwDB.Items($$lvwDBIndex).Remove ENDIF $$txtDBName.SetFocus ENDIF'
$btnDBDone = $frmDB.ToolButton $btnDBDone.ToolTip = 'Go back to the Main Window' $btnDBDone.Size = $iToolButtonWidth, $iToolButtonHeight $btnDBDone.Location = $frmDB.Width - $btnDBDone.Width - $iMargin, $txtDBName.Top - 2 $btnDBDone.FlatStyle = 1 $btnDBDone.Alignment = 0 $btnDBDone.Icon = $ilsicons.Images(5) $btnDBDone.OnClick = '$$frmDB.Hide' ;--- DB form
$aSMSTSM = $aSMSTSMID,$aSMSTSMName $aSMSTSMTitles = 'SMS TSM Collection IDs','SMS TSM Collection Names' $aSMSTSM = fnDB($aSMSTSM, $aSMSTSMTitles) ? UBound($aSMSTSM) FOR EACH $k IN $aSMSTSM ? UBound($k) FOR EACH $r IN $k ? $r NEXT NEXT QUIT 0
FUNCTION fnDB($aDBList, OPTIONAL $DBTitle) DIM $Index, $Index2, $DBTemp, $ColumnIndex, $ColumnName, $Column FOR $ColumnIndex = 0 TO $lvwDB.Columns.Count - 1 $lvwDB.Columns($ColumnIndex).Remove NEXT $lvwDB.Items.Clear IF UBound($aDBList[1]) > 0 SELECT CASE UBound($DBTitle) > 0 FOR EACH $ColumnName IN $DBTitle $Nul = $lvwDB.Columns.Add($ColumnName,, 0) NEXT CASE $DBTitle <> '' FOR $Index = 0 TO UBound($aDBList) IF $Index = 0 $Nul = $lvwDB.Columns.Add($DBTitle,, 0) ELSE $Nul = $lvwDB.Columns.Add($Index,, 0) ENDIF NEXT CASE $DBTitle = '' FOR $Index = 0 TO UBound($aDBList) $Nul = $lvwDB.Columns.Add($Index,, 0) NEXT $lvwDB.HeaderStyle = 0 ENDSELECT ELSE SELECT CASE UBound($DBTitle) > 0 $Nul = $lvwDB.Columns.Add($DBTitle[0],, 0) CASE $DBTitle <> '' $Nul = $lvwDB.Columns.Add($DBTitle,, 0) CASE $DBTitle = '' $Nul = $lvwDB.Columns.Add(0,, 0) $lvwDB.HeaderStyle = 0 ENDSELECT ENDIF IF UBound($aDBList[1]) > 0 $lvwDB.Items.Count = Val (UBound($aDBList[0]) + 1) FOR $Index = 0 TO Val(UBound($aDBList[$Index2])) FOR $Index2 = 0 TO Val(UBound($aDBList)) $lvwDB.Items($Index).SubItems($Index2).Text = $aDBList[$Index2][$Index] NEXT NEXT ELSE $lvwDB.Items.Count = Val (UBound($aDBList) + 1) FOR $Index = 0 TO Val(UBound($aDBList)) $lvwDB.Items($Index).SubItems(0).Text = $aDBList[$Index] NEXT ENDIF FOR EACH $Column IN $lvwDB.Columns $Column.Width = -1 $Column.Width = -2 NEXT $spnDBName.Min = 0 $spnDBName.Max = $lvwDB.Columns.Count - 1
$frmDB.Show $frmDB.SetFocus $txtDBName.SetFocus WHILE $frmDB.Visible $Nul = Execute($frmDB.DoEvents()) LOOP DIM $aDBTemp [Val($lvwDB.Columns.Count - 1)] FOR $Index = 0 TO Val($lvwDB.Items.Count - 1) FOR $Index2 = 0 TO Val(UBound($aDBTemp)) $aDBTemp[$Index2] = $aDBTemp[$Index2] + $lvwDB.Items($Index).SubItems($Index2).Text + ',' NEXT NEXT FOR $Index = 0 TO Val(UBound($aDBTemp)) $DBTemp = Substr($aDBTemp[$Index], 1, Len($aDBTemp[$Index]) - 1) $aDBTemp[$Index] = Split($DBTemp, ',', -1) NEXT $fnDB = $aDBTemp ENDFUNCTION
[ 18. February 2003, 03:27: Message edited by: krabourn ]
_________________________
Kelly
|
Top
|
|
|
|
#91473 - 2003-02-16 10:18 PM
Re: KixForms - Typing inside ListView
|
krabourn
Hey THIS is FUN
Registered: 2000-12-11
Posts: 244
Loc: San Antonio, Texas, USA
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 515 anonymous users online.
|
|
|