KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

$Listview.Items.Clear seems to be broken

 
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion
View previous topic :: View next topic  
Author Message
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Fri Aug 06, 2004 7:58 am    Post subject: $Listview.Items.Clear seems to be broken Reply with quote

Shawn,

remember this password input thingie I showed you this week ?
Allthough it gets created in a function where I dim all the objects and the Listview gets entirely re-created it appears that on a second call ´the Listview contents (items) are doubled Shocked

I tried several methods to get rid of this. Amonst others with $listview.Columns.Clear and $ListView.Items.Clear ... even $Listview.Dispose.

Nothing worked Stunned

I may even send you the actual work in progress if you have time to review

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Fri Aug 06, 2004 11:07 am    Post subject: Reply with quote

ja - send me the script or post a scriptlet cappy.
Back to top
View user's profile Send private message
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Fri Aug 06, 2004 11:13 am    Post subject: Reply with quote

Think I will post a scriptlet.

Wonder if I can reproduce this behavior with it as the original is quite bloated Rolling Eyes

Thanx

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Fri Aug 06, 2004 11:32 am    Post subject: Reply with quote

Ok I got it condensed in a 'small' scriptlet Cool
So basically on clicking the Button 'User Options' it will create a list of domain Users and feed them to the ListView .... There you can edit Passwords ... Clicking the button again closes the Listview subform and SHOULD terminate the ListView ... BUT If you click on 'User Options' the third time the Userlist is doubled as if the list gets attached on the first

Code:
break on

$system = createobject("Kixtart.System")

$dlgFrm           = $system.Form($form)
$dlgFrm.Size      = 250,210

$btnPwd           = $dlgFrm.ToolButton()
$btnPwd.Alignment = 1
$btnPwd.Text      = 'User Options'
$btnPwd.Style     = 1
$btnPwd.Icon      = 30
$btnPwd.Size      = 100,23
$btnPwd.Location  = $dlgFrm.CLientWidth - 105, 50
$btnPwd.OnClick   = "if $$btnPwd.Pushed
                         $$_ = Dlg_SetPasswords($$btnPwd, $$dlgFrm, $$btnPwd.Pushed)
                     else
                         $$obj.Icon = 30
                         for $$i = $$w to 0 step -2
                             $$grpPwd.Top = $$i - $$w
                             $$dlgFrmPwd.ClientHeight = $$i
                             if $$i < 20
                                 sleep 0.012
                             endif
                         next
                         $$lvwPwd.Items.Clear ; <----- [HINT] THIS IS THE LINE THAT DOESN'T DO WHAT IT SHOULD [/HINT]
                         $$dlgFrmPwd.Hide
                     endif"

$dlgFrm.Show

while $dlgFrm.Visible
    $_ = execute($dlgFrm.DoEvents)
loop

exit 1

function Dlg_SetPasswords($obj, $objParent, $btnPushed)
    dim $dlgFrmPwd, $grpPwd, $lblPwd, $txtPwd, $lvwPwd, $w, $l, $n, $key, $usrA
    $obj.Icon = 31
    $dlgFrmPwd                           = $system.Form($objParent)
    $dlgFrmPwd.BorderStyle               = 0
    $dlgFrmPwd.KeyPreview                = 1
    $dlgFrmPwd.Size                      = $objParent.ClientWidth + 8, 230
    $dlgFrmPwd.Location                  = $objParent.Left, $objParent.Bottom

    $grpPwd                              = $dlgFrmPwd.GroupBox()
    $grpPwd.Location                     = 0,0
    $grpPwd.Size                         = $dlgFrmPwd.ClientWidth, $dlgFrmPwd.ClientHeight
    $grpPwd.BorderStyle                  = 0

    $lblPwdLength                        = $grpPwd.Controls.Label("Minimum Password Length:",1,6,135,20)
    $lblPwdLength.BorderStyle            = 0
    $lblPwdLength.ToolTipText            = "Specifiy the Minimum Password length as given in" + chr(10) +
                                           "the Account Policies of the Server you Export the Users to." + chr(10) +
                                           "Choose 0 if blank Passwords are allowed by this Policy" + chr(10) +
                                           "Maximum length will always be 14 characters."

    $cboPwdLength                        = $grpPwd.Controls.ComboBox("",$lblPwdLength.Right,3,40,20)
    $cboPwdLength.DropDownStyle          = 2
    $cboPwdLength.List                   = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14
    $cboPwdLength.OnSelectedIndexChanged = "$$MinPwdLength = $$cboPwdLength.ListIndex"

    $lblPwd                              = $grpPwd.Controls.Label("Standard Password:",1,$lblPwdLength.Bottom + 6,100,20)
    $lblPwd.BorderStyle                  = 0
    $lblPwd.ToolTipText                  = "This Password will be used on Import" + chr(10) + "if none is specified in the List below"

    $txtPwd                              = $grpPwd.Controls.TextBox("",$cboPwdLength.Left,$lblPwdLength.Bottom + 3,$grpPwd.ClientWidth - $cboPwdLength.Left - 2,20)
    $txtPwd.PasswordChar                 = "*"
    $txtPwd.MaxLength                    = 14


    $lvwPwd                              = $grpPwd.Controls.ListView()
    $lvwPwd.Bounds                       = 0,$lblPwd.Bottom + 3,$grpPwd.ClientWidth,$grpPwd.ClientHeight-$lblPwd.Bottom - 3
    $lvwPwd.GridLines                    = 1
    $lvwPwd.ToolTipText                  = "Doubleclick an Item to add a Password for this User, type the Password" + chr(10) +
                                           "and confirm with ENTER; If the password is shorter than the specified minimum" + chr(10) +
                                           "length or longer than 14 characters, the control won't react on ENTER" + chr(10) +
                                           "To remove a Password on the list, doubleclick the Item and hit ESCAPE" + chr(10) +
                                           "To review the Passwords highlight the list and hold down the CTRL-Key"
    $lvwPwd.OnDblClick                   = "Dlg_InputPassword($$lvwPwd, $$dlgFrmPwd, $$obj, $$lvwPwd.SelectedIndex, $$lvwPwd.MouseY)"
    $lvwPwd.OnKeyDown                    = "if $$lvwPwd.KeyCode = 17 and not $$Key
                                                $$txtPwd.PasswordChar = ''
                                                for each $$itm in $$lvwPwd.Items
                                                    if $$itm.Tag
                                                         $$itm.SubItems(1).Text = $$itm.Tag
                                                    endif
                                                next
                                                $$Key = 1
                                                while $$lvwPwd.KeyState(17)
                                                    $$_ = execute($$dlgFrmPwd.DoEvents(1))
                                                    sleep 0.001
                                                loop
                                                $$Key = 0
                                                for each $$itm in $$lvwPwd.Items
                                                    if $$itm.Tag
                                                         $$itm.SubItems(1).Text = ''
                                                         for $$i = 0 to len($$itm.Tag)
                                                             $$itm.SubItems(1).Text = $$itm.SubItems(1).Text + '*'
                                                         next
                                                    endif
                                                next
                                                $$txtPwd.PasswordChar = '*'
                                            endif"

    $_                                   = $lvwPwd.Columns.Add("Username",120)
    $_                                   = $lvwPwd.Columns.Add("Password",$lvwPwd.ClientWidth-17-$lvwPwd.Columns(0).Width)

    $w                                   = $dlgFrmPwd.ClientHeight
    $dlgFrmPwd.ClientHeight              = 0
    $dlgFrmPwd.Show
    $objParent.Cursor = 11
    for $i = 0 to $w step 2
        $grpPwd.Top = -$w + $i
        $dlgFrmPwd.ClientHeight = $i
        if $i > $w - 20
            sleep 0.012
        endif
    next
    $dlgFrmPwd.Cursor = 11
    $usrA = Enum_USR("foo")
    for $i = 0 to ubound($usrA)
        if $usrA[$i]
            $_ = $lvwPwd.Items.Add($usrA[$i])
        endif
    next
    $dlgFrmPwd.Cursor = 1
    $objParent.Cursor = 1
    while $dlgFrmPwd.Visible
        $_ = execute($dlgFrmPwd.DoEvents)
        $_ = execute($objParent.DoEvents)
    loop
endfunction

function Dlg_InputPassword($objParent, $objParent1, $objButton, $index, optional $MouseY)
    if $PwdInputRunning exit 1 endif
    $PwdInputRunning = 1
    dim $txt1, $i
    $objParent.Items($index).SubItems(1).Text = ""
    $objParent.Items($index).Tag              = ""
    $objButton.Enabled  = 0
    $txt1               = $objParent.Controls.TextBox()
    $txt1.ClientWidth   = $objParent.Columns(1).Width - 3
    $txt1.Location      = $objParent.Columns(0).Width, $MouseY / 14 * 14 + 4
    if $txt1.Top >= $MouseY
        $txt1.Top = $txt1.Top - 14
    endif
    $txt1.ClientHeight  = 12
    $txt1.MaxLength     = 14
    $txt1.PasswordChar  = '*'
    $txt1.OnKeyDown     = "select
                               case $$txt1.KeyCode = 13
                                   if len($$txt1.Text) >= $$MinPwdLength
                                       $$objParent.Items($$index).Tag = $$txt1.Text
                                       for $$i = 1 to len($$txt1.Text)
                                           $$objParent.Items($$index).SubItems(1).Text = $$objParent.Items($$index).SubItems(1).Text + '*'
                                       next
                                       $$txt1.dispose
                                   endif
                               case $$txt1.KeyCode = 27
                                   $$objParent.Items($$index).Tag = ''
                                   $$objParent.Items($$index).SubItems(1).Text = ''
                                   $$txt1.dispose
                           endselect"
    while $txt1.Visible
        $_ = execute($objParent1.DoEvents)
    loop
    $objButton.Enabled = 1
    $PwdInputRunning = 0
endfunction

function Enum_USR($title)
    select
        case $title = "Export"

        case $title = "Import"

        case 1
            dim $l, a
            shell '%ComSpec% /c net user /domain >"'+$tmp+'\users.tmp"'
            $_ = open(1,$tmp+'\users.tmp')
            while not instr($l,'-----') and not @error
                $l = readline(1)
            loop
            $l = readline(1)
            while not @error and ( not instr($l,"The Command") and not instr($l,"Der Befehl") )
                $a = $a + trim(substr($l,1,25)) + chr(10) +  trim(substr($l,26,25)) + chr(10) + trim(substr($l,51,25)) + chr(10)
                $l = readline(1)
            loop
            $a = left($a,-1)
            $_ = close(1)
            del $tmp+'\users.tmp'
            $Enum_USR = split($a,chr(10))
    endselect
endfunction


[edit] removed some more unrelated crap out of it [/edit]

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Fri Aug 06, 2004 12:56 pm    Post subject: Reply with quote

Oh yeah by the way for those who are not interested in fixing this:

This one is also a sample on how to overlay TextBoxes on doubleclicked Listview SubItems Cunning

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Fri Aug 06, 2004 12:57 pm    Post subject: Reply with quote

there's my EXCEL!
jochen, I love you!

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Fri Aug 06, 2004 12:57 pm    Post subject: Reply with quote

*smooch*
_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Mon Aug 09, 2004 7:11 am    Post subject: Reply with quote

Allright.

I couldn't reproduce this with a simple single form Rolling Eyes

Code:
break on

$system = createobject("Kixtart.System")

$dlgFrm           = $system.Form()
$dlgFrm.Size      = 250,210

$l                = $dlgFrm.ListView()
$l.Bounds         = 0,50,$dlgFrm.ClientWidth,160
$l.GridLines      = 1
$_                = $l.Columns.Add("Content",$l.ClientWidth/2)
$_                = $l.Columns.Add("",$l.ClientWidth/2)

$b1               = $dlgFrm.ToolButton("Add Content",5,5,80,25)
$b1.OnClick       = "for $$i = 0 to 4 $$item = $$l.Items.Add('item $$i') $$item.Tag = 'item $$i' next"

$b2               = $dlgFrm.ToolButton("Clear Content",$b1.Right + 5,5,80,25)
$b2.OnClick       = "$$l.Items.Clear"

$dlgFrm.Show

while $dlgFrm.Visible
    $_ = execute($dlgFrm.DoEvents)
loop

exit 1


This works as it should.

Still wonder why it doesn't work in the complex version above as the method should be executed ... will research a bit more and get back to you.

Another pair of eyes is still welcome !

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Mon Aug 09, 2004 8:42 am    Post subject: Reply with quote

Ok, got it nailed down a bit more but still can't spot the looney.
Maybe it got something to do with the passed object ?!?

Head Hurts Head Hurts Head Hurts

here da scriptlet:

Code:
break on

$tmp = @scriptdir

$system = createobject("Kixtart.System")

$dlgFrm           = $system.Form()
$dlgFrm.Size      = 250,210

$l                = $dlgFrm.ListView()
$l.Bounds         = 0,50,$dlgFrm.ClientWidth,160
$l.GridLines      = 1
$_                = $l.Columns.Add("Content",$l.ClientWidth/2)
$_                = $l.Columns.Add("",$l.ClientWidth/2)

$b1               = $dlgFrm.ToolButton("Add Content",5,5,80,25)
$b1.OnClick       = "$$_ = Add($$l)"

$b2               = $dlgFrm.ToolButton("Clear Content",$b1.Right + 5,5,80,25)
$b2.OnClick       = "$$l.Items.Clear"

$dlgFrm.Show

while $dlgFrm.Visible
    $_ = execute($dlgFrm.DoEvents)
loop

exit 1

function add($obj)
    dim $usrA, $i
    $usrA = Enum_USR('foo')
    for $i = 0 to ubound($usrA)
        if $usrA[$i]
            $_ = $obj.Items.Add($usrA[$i])
        endif
    next
endfunction

function Enum_USR($title)
    select
        case $title = "Export"

        case $title = "Import"

        case 1
            dim $l, a
            shell '%ComSpec% /c net user /domain >"'+$tmp+'\users.tmp"'
            $_ = open(1,$tmp+'\users.tmp')
            while not instr($l,'-----') and not @error
                $l = readline(1)
            loop
            $l = readline(1)
            while not @error and ( not instr($l,"The Command") and not instr($l,"Der Befehl") )
                $a = $a + trim(substr($l,1,25)) + chr(10) +  trim(substr($l,26,25)) + chr(10) + trim(substr($l,51,25)) + chr(10)
                $l = readline(1)
            loop
            $a = left($a,-1)
            $_ = close(1)
            del $tmp+'\users.tmp'
            $Enum_USR = split($a,chr(10))
    endselect
endfunction

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Mon Aug 09, 2004 10:02 am    Post subject: Reply with quote

OHMYGODWTF Shocked Sick Scream

I forgot a single $ in the dim line in the Enum_USR udf.
That made the temp var Global and all subsequent enums were added to it ...

Quote:
dim $l, a
was the cause.

I feel very Embarassed Embarassed Embarassed now´, sorry for the false alert

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group