Jump to content

Why does GUICtrlCreateListView keep adding?


Recommended Posts

;***********************
; Sample GUI Menu V2
; Coded by: Dan
; August 2, 2006
;Special Thanks to: gafrost, SmOke_N, Skruge, Paulie, and codemyster!
;***********************

#include <GuiConstants.au3>
#include <Misc.au3>
#include <File.au3>
#include <GuiListView.au3>
FileWrite("c:/blank.txt", "")
Global $oRP

$name = InputBox("Log In", "Please enter your name:")

; GUI
GUICreate("Sample GUI Menu", 400, 400)
GUISetIcon(@SystemDir & " notepad.exe", 0)
$TagsPageC = GUICtrlCreateLabel('Visit AutoIt Homepage', 5, 399, 100, 15, $SS_CENTER)
GUICtrlSetFont($TagsPageC, 9, 400, 4)
GUICtrlSetColor($TagsPageC, 0x0000ff)
GUICtrlSetCursor($TagsPageC, 0)
GUICtrlCreateLabel ("GUICtrlCreateLabel",  100, 400)


; BANNER
$s_TempFile = _TempFile()
InetGet("http://i37.photobucket.com/albums/e91/Zombie1992/logo4.gif", $s_TempFile)
GUICtrlCreatePic($s_TempFile, 0, 0, 400, 67)

; SLIDER
GUICtrlCreateLabel("Slider:", 235, 325)
GUICtrlCreateSlider(270, 325, 120, 30)
GUICtrlSetData(-1, 30)

; TEXT
GUICtrlCreateLabel("This is the text for a Main Menu! This is the text for a Main Menu! This is the text for a Main Menu! This is the text for a Main Menu! This is the text for a Main Menu! This is the text for a Main MenuV2!", 10, 275, 389, 37)
$label = GUICtrlCreateLabel("Logged in as: " & $name, 150, 75, 400, 14)
;GUICtrlSetStyle (-1, $SS_RIGHT )

; MENU
$filemenu = GUICtrlCreateMenu("File")
$fileitem = GUICtrlCreateMenuitem("Open...", $filemenu)
$recentfilesmenu = GUICtrlCreateMenu("Recent Files", $filemenu)
$separator1 = GUICtrlCreateMenuitem("", $filemenu)
$exititem = GUICtrlCreateMenuitem("Exit", $filemenu)
$helpmenu = GUICtrlCreateMenu("About")
$aboutitem = GUICtrlCreateMenuitem("About", $helpmenu)

; TAB
GUICtrlCreateTab(1, 70, 400, 190)
$tab1 = GUICtrlCreateTabItem("Intro")
GUICtrlCreateLabel("Welcome to Sample GUI Menu V2." & @CRLF & " " & @CRLF & "Sample Gui Program Is In Launch. This is a sample gui with features such as login, tabs, clickable links, and NotePad Feature! ", 20, 120, 385, 100)
GUICtrlCreateTabItem("Info")
$Edit_1 = GuiCtrlCreateEdit("Welcome to SimpleEdit 1.1 Created by: codemyster", 15, 100, 373, 120)
$Button_2 = GuiCtrlCreateButton("New", 20, 220, 100, 30)
$Button_3 = GuiCtrlCreateButton("Save", 220, 220, 100, 30)
$Button_7 = GuiCtrlCreateButton("Open", 120, 220, 100, 30)
GUICtrlCreateTabItem("AutoIt")
$treeview       = GUICtrlCreateTreeView(15, 100, 100, 150, BitOr($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$generalitem    = GUICtrlCreateTreeViewitem("General", $treeview)
GUICtrlSetColor(-1, 0x0000C0)
$displayitem    = GUICtrlCreateTreeViewitem("Users", $treeview)
GUICtrlSetColor(-1, 0x0000C0)
$compitem       = GUICtrlCreateTreeViewitem("Computer", $generalitem)
$useritem       = GUICtrlCreateTreeViewitem("User", $generalitem)
$resitem        = GUICtrlCreateTreeViewitem("Resolution", $displayitem)
$otheritem      = GUICtrlCreateTreeViewitem("Other", $displayitem)

Dim $listview, $button, $msg, $i, $ret, $s_item
$listview = GUICtrlCreateListView("Col1|Col2|Col3|Col4", 120, 100, 200, 100, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_HEADERDRAGDROP, $LVS_EX_HEADERDRAGDROP)
_GUICtrlListViewSetItemCount($listview, 20)
; GUI MESSAGE        LOOP

GUICtrlCreateTabItem("")   ; end tabitem definition
GUICtrlSetState($tab1, $GUI_SHOW)   ; will be display first

GUISetState()

While 1
    $msg = GUIGetMsg()
   
    Select
        Case $msg = $fileitem
            $file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)")
            If @error <> 1 Then GUICtrlCreateMenuitem($file, $recentfilesmenu)
        Case $msg = $exititem
            ExitLoop
        Case $msg = $GUI_EVENT_CLOSE
;~    $oRP.SaveFile (@ScriptDir & "RichText.rtf", 0)
            ExitLoop
           
        Case $msg = $TagsPageC
            Run(@ComSpec & ' /c start http://www.autoitscript.com/autoit3%27"]http://www.autoitscript.com/autoit3', '', @SW_HIDE)
           
        Case $msg = $aboutitem
            MsgBox(0, "About Sample GUI Menu V2", "Sample GUI Menu V2" & @CRLF & @CRLF & "Created by: Javascript_Freek" & @CRLF & "" & @CRLF & "©AutoIt")
        Case $msg = $GUI_EVENT_CLOSE
               $msg = GuiGetMsg()
        Case $msg = $Button_2
        GUICtrlSetData($Edit_1, "")
        Case $msg = $Button_3
       FileWrite(FilesaveDialog("Select a file to save",@ScriptDir, "All Files (*.*)"),GUICtrlRead($Edit_1))
       Case $msg = $Button_7
       GUICtrlSetData($Edit_1,Fileread(FileOpenDialog("Select a file to open",@ScriptDir, "All Files (*.*)")))
      Case $msg = $GUI_EVENT_CLOSE
         ExitLoop
      Case $msg = $button
            For $i = 0 To 9
                $s_item = $i & "|" & $i & "|" & $i & "|" & $i
                GUICtrlCreateListViewItem($s_item, $listview)
            Next
    EndSelect
WEnd

When you launch it the list on the third tab keeps adding. Why does this happen? :whistle:

Not the list itself but the numbers inside.

Edited by JavaScript_Freek

[center]Cookyx.com :: Simple LAN Chat[/center]

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