Jump to content

clear previous listview


 Share

Recommended Posts

Func set_group()
    
    Local $group_info, $Address_info 
    
;populates group view
    $group_info = GUICtrlRead($child3A_combo1)
    If $group_info = "" Then
        MsgBox(64,"Gruop View Error", "Please Select a Group Name First  ")
        Return
    EndIf
    $Address_info = IniReadSection(@ScriptDir & '\ChatClient.ini',$group_info)
    If @error =1 Then
        MsgBox(64,"Gruop View Error #1", "Section Not Found  ")
        Return
    EndIf
    If @error =2 Then
        MsgBox(64,"Gruop View Error #2", "The Section was Empty or Incorrect Format  ")
        Return
    EndIf
    GUICtrlSetData($listview,"|")
    For $x = 1 To $Address_info[0][0] 
      GUICtrlCreateListViewItem($Address_info[$x][1], $listview) 
    Next 
EndFunc

like that

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

know what your trying to do, but just as a quick example:

#include <GUIConstants.au3>
#include <GuiListView.au3>

GUICreate("listview items",220,250, 100,200,-1,$WS_EX_ACCEPTFILES)
GUISetBkColor (0x00E0FFFF) ; will change background color

$listview = GUICtrlCreateListView ("col1  |col2|col3|col4  ",10,10,200,150,BitOR($LVS_SHOWSELALWAYS,$LVS_SORTDESCENDING))
;~ $listview = GUICtrlCreateListView ("col1  |col2|col3|col4  ",10,10,200,150,BitOR($LVS_SHOWSELALWAYS,$LVS_SORTASCENDING))
$button = GUICtrlCreateButton ("Value?",75,170,70,20)
$item1=GUICtrlCreateListViewItem("item2|col22|col23|col24",$listview)
$item2=GUICtrlCreateListViewItem("item1|col12|col13|col14",$listview)
$item3=GUICtrlCreateListViewItem("item3|col32|col33|col34",$listview)
$input1=GUICtrlCreateInput("",20,200, 150)
GUICtrlSetState(-1,$GUI_ACCEPTFILES)  ; to allow drag and dropping
GUISetState()

;**********************************************************
For $x = 0 To _GUICtrlListViewGetSubItemsCount($listview) - 1
    _GUICtrlListViewSetItemText($listview,1,$x,"")
Next
;**********************************************************

Do
  $msg = GUIGetMsg ()
     
   Select
      Case $msg = $button
         MsgBox(0,"listview item",GUICtrlRead(GUICtrlRead($listview)),2)
      Case $msg = $listview
         MsgBox(0,"listview", "clicked="& GUICtrlGetState($listview),2)
   EndSelect
Until $msg = $GUI_EVENT_CLOSE
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

here ya be

; Includes 
#include <GUIConstants.au3> 

#region **** install files if needed **** 
If @Compiled Then 
   If Not FileExists(@ScriptDir & '\ChatClient.ini') Then FileInstall("c:\AutoitITS\ChatClient.ini", @ScriptDir & '\ChatClient.ini') 
EndIf 
#endregion **** end install files if needed **** 

Global $child3A_combo1, $listview

_Main() 

#region --- _Main Function --- 
Func _Main() 
   opt('MustDeclareVars', 1) 
   #region --- DEVELOPERS SETTINGS --- 
  ;******************************************************** 
  ;DEVELOPERS SETTINGS 
   Local $initial_view, $Address_Book, $Text_to_Cell, $online_view, $Address_info 
  ; END DEVELOPER SETTINGS 
  ;******************************************************** 
   #endregion --- END DEVELOPER SETTINGS --- 
   Local $hide_button, $show_button, $online_list 
    
  ; set up functions 
   Initilaize($initial_view, $Address_Book, $Text_to_Cell, $online_view, $Address_info) 
   #region ---- GUI Variables Declarations ---- 
   Local $hImageList = 0 
   
    

   Local $main_GUI, $send_box, $send_button, $_simple, $view_button, $help_button, $cancel_button 
   Local $display, $msg, $btn_msg, $send_info, $tabidx, $x 
   Local $child1, $child1_tab, $child1_tabitem1, $child1_tabitem2, $child1_tabitem3 
   Local $child2, $child2_view 
   Local $child3A, $child3B, $child3A_tab, $child3A_tabitem1, $child3A_tabitem2, $child3A_button1, $child3A_label1A, $child3A_button1A  
   Local $child4, $child4_view, $child4_input, $child4_button 
   Local $main_tab, $main_tabitem1, $main_tabitem2, $main_tabitem3, $main_tabitem4 
   #endregion ---- END GUI Variables Declarations ---- 
   $main_GUI = GUICreate("Autoit-ITS   Connection Center", 400, 360, -1, -1);, BitOr($GUI_SS_DEFAULT_GUI,$WS_CLIPSIBLINGS)) 
  ; create send text 
   $send_box = GUICtrlCreateEdit("Type your text here", 10, 260, 300, 60) 
   $send_button = GUICtrlCreateButton("S&end", 320, 278, 70, 30) 
   GUICtrlSetState(-1, $GUI_DEFBUTTON) 
    
  ; creates edit for simple view 
   $_simple = GUICtrlCreateEdit("Your last text conversation", 15, 40, 370, 215) 
   GUICtrlSetState(-1, $GUI_HIDE) 
    
  ; create control buttons 
   $view_button = GUICtrlCreateButton("&Simple", 20, 330, 70, 20) 
   If $online_view = 1 Then $show_button = GUICtrlCreateButton("S&how List", 120, 330, 70, 20) 
   $help_button = GUICtrlCreateButton("&Help", 220, 330, 70, 20) 
   $cancel_button = GUICtrlCreateButton("&Cancel", 320, 330, 70, 20) 
   GUISetState() 
    
    
  ; Creates the first child window that is implemented into the main GUI 
   $child1 = GUICreate("", 370, 215, 15, 40, BitOR($WS_CHILD, $WS_TABSTOP), -1, $main_GUI) 
  ;GUISetBkColor(0x257788); just for dimensing the child 
   $child1_tab = GUICtrlCreateTab(0, 0, 370, 215) 
   $child1_tabitem1 = GUICtrlCreateTabItem("Connections") 
   $child1_tabitem2 = GUICtrlCreateTabItem("Administration") 
   $child1_tabitem3 = GUICtrlCreateTabItem("Options") 
   GUICtrlCreateTabItem("") 
   GUISetState(@SW_HIDE) 
    
  ; create chat view text 
   $child2 = GUICreate("", 370, 215, 15, 40, BitOR($WS_CHILD, $WS_TABSTOP), -1, $main_GUI) 
   $child2_view = GUICtrlCreateEdit("Your last text conversation", 0, 0, 370, 215) 
   GUISetState(@SW_HIDE) 
    
    
  ; Creates the second child window that is implemented into the main GUI 
   $child3A = GUICreate("", 370, 215, 15, 40, BitOR($WS_CHILD, $WS_TABSTOP), -1, $main_GUI) 
  ;GUISetBkColor(0x257788); just for dimensing the child 
    
   $child3B = GUICreate("", 210, 220, 158, 0, BitOR($WS_CHILD, $WS_TABSTOP), -1, $child3A) 
  ;GUISetBkColor(0x257788) 
   
   
   
   
   
   
   
   $listview = GUICtrlCreateListView("Name|Screen Name|Member", 0, 2, 210, 211, BitOR($LVS_NOSORTHEADER, $LVS_SHOWSELALWAYS, $WS_TABSTOP), $WS_EX_CLIENTEDGE) 
  ;For $x = 1 To $Address_info[0][0] 
  ;   GUICtrlCreateListViewItem($Address_info[$x][1], $listview) 
  ;Next 
   GUISetState(@SW_HIDE) 
    
  ; create chat view text 
   $child4 = GUICreate("", 370, 215, 15, 40, BitOR($WS_CHILD, $WS_TABSTOP), -1, $main_GUI) 
   $child4_view = GUICtrlCreateEdit("Your last Text to Cell Phone", 0, 0, 370, 150) 
   $child4_input = GUICtrlCreateInput("Cell Number", 20, 170, 200, 20) 
   $child4_button = GUICtrlCreateButton("&Connect", 250, 168, 70, 25) 
   GUISetState(@SW_HIDE) 
    
   GUISwitch($child3A) 
   $child3A_tab = GUICtrlCreateTab(0, 0, 156, 215) 
   $child3A_tabitem1 = GUICtrlCreateTabItem("Group View")
    GUICtrlCreateLabel("Choose a Group to View", 15, 35, 125, 20)
    $child3A_combo1 = GUICtrlCreateCombo("", 15, 55, 120, 20)
    GUICtrlSetData( -1, "Autoit|Family|Friends|Personal|Business|Associates|Classmates")
    $child3A_button1 = GUICtrlCreateButton("S&elect", 40, 90, 70, 20)
    GUICtrlCreateLabel("Name to Send Text", 25, 130, 125, 20)
    $child3A_label1A = GUICtrlCreateLabel("Select from Group List", 15, 150, 120, 20, $SS_SUNKEN + $SS_CENTER)
    $child3A_button1A = GUICtrlCreateButton("Se&lect", 40, 180, 70, 20)
   $child3A_tabitem2 = GUICtrlCreateTabItem("Name View") 
   GUICtrlCreateTabItem("") 
    
  ; Switch back the main GUI and create the tabs 
   GUISwitch($main_GUI) 
   $main_tab = GUICtrlCreateTab(10, 10, 380, 250) 
   $main_tabitem1 = GUICtrlCreateTabItem("Controls") 
   $main_tabitem2 = GUICtrlCreateTabItem("Chat View") 
   If $Address_Book = 1 Then $main_tabitem3 = GUICtrlCreateTabItem("Address Book") 
   If $Text_to_Cell = 1 Then $main_tabitem4 = GUICtrlCreateTabItem("Text to Cell") 
   GUICtrlCreateTabItem("") 
   GUICtrlSetState($main_tabitem1, $GUI_HIDE) 
    
   Bind_ImageList($main_GUI, $main_tab, $hImageList, $Address_Book, $Text_to_Cell) 
    
  ; create a who is online list 
  ;$online_list = GUICreate("Autoit-ITS   Online Center", 210, 340, 10, 10) 
   $online_list = GUICreate("Autoit-ITS Online Center", 210, 340, 10, 10, $WS_POPUP + $WS_CAPTION, -1, $main_GUI) 
  ; create list display 
   $display = GUICtrlCreateEdit("Who's - Online", 10, 10, 190, 280) 
   If $online_view = 1 Then $hide_button = GUICtrlCreateButton("H&ide List", 70, 310, 70, 20) 
   GUISetState(@SW_HIDE, $online_list) 
    
    
   set_view($initial_view, $child1, $child2, $child3A, $child3B, $child4, $main_tab, $child1_tab, $child2_view, _ 
         $_simple, $view_button, $main_tabitem1) 
   _ReduceMemory() 
   While 1 
      $msg = GUIGetMsg(1) 
      Select 
         Case $msg[0] = $GUI_EVENT_CLOSE Or $msg[0] = $cancel_button 
            ExitLoop 
         Case $msg[0] = $hide_button 
            GUISetState(@SW_HIDE, $online_list) 
            GUICtrlSetData($show_button, "S&how List") 
         Case $msg[0] = $show_button 
            $btn_msg = GUICtrlRead($show_button) 
            If $btn_msg = "H&ide List" Then 
               GUISetState(@SW_HIDE, $online_list) 
               GUICtrlSetData($show_button, "S&how List") 
            Else 
               GUISetState(@SW_SHOW, $online_list) 
               GUICtrlSetData($show_button, "H&ide List") 
            EndIf 
         Case $msg[0] = $help_button 
            help_center() 
         Case $msg[0] = $view_button 
            set_view($initial_view, $child1, $child2, $child3A, $child3B, $child4, $main_tab, $child1_tab, $child2_view, _ 
                  $_simple, $view_button, $main_tabitem1) 
         Case $msg[0] = $send_button 
            $send_info = GUICtrlRead($send_box) 
            If $send_info <> "" Then 
               GUICtrlSetData($_simple, @CRLF & $send_info, -1) 
               GUICtrlSetData($child2_view, @CRLF & $send_info, -1) 
               send_message($send_info) 
           EndIf
       Case $msg[0] = $child3A_button1 
            set_group() 
         Case $msg[0] = $main_tab 
            $tabidx = GUICtrlRead($main_tab) 
            Select 
               Case $tabidx = 0 
                  GUISetState(@SW_HIDE, $child4) 
                  GUISetState(@SW_HIDE, $child2) 
                  GUISetState(@SW_HIDE, $child3A) 
                  GUISetState(@SW_SHOW, $child1) 
                   
               Case $tabidx = 1 
                  GUISetState(@SW_HIDE, $child4) 
                  GUISetState(@SW_HIDE, $child3A) 
                  GUISetState(@SW_HIDE, $child1) 
                  GUISetState(@SW_SHOW, $child2) 
                   
               Case $tabidx = 2 
                  GUISetState(@SW_HIDE, $child4) 
                  GUISetState(@SW_SHOW, $child3A) 
                  GUISetState(@SW_HIDE, $child2) 
                  GUISetState(@SW_HIDE, $child1) 
               Case $tabidx = 3 
                  GUISetState(@SW_SHOW, $child4) 
                  GUISetState(@SW_HIDE, $child2) 
                  GUISetState(@SW_HIDE, $child3A) 
                  GUISetState(@SW_HIDE, $child1) 
            EndSelect 
      EndSelect 
   WEnd 
    
   DllCall("comctl32.dll", "int", "ImageList_Destroy", "hwnd", $hImageList) 
   Exit 
EndFunc  ;==>_Main 
#endregion --- END _Main Function --- 
;-------------------------------------- GUI Functions -------------------------------------- 

Func ImageList_Create(ByRef $hImageList) 
   $hImageList = DllCall("comctl32.dll", "hwnd", "ImageList_Create", "int", 16, "int", 16, "int", 0x0021, "int", 0, "int", 1) 
   $hImageList = $hImageList[0] 
   Return $hImageList 
EndFunc  ;==>ImageList_Create 

Func Bind_ImageList(ByRef $main_GUI, ByRef $nCtrl, ByRef $hImageList, ByRef $Address_Book, ByRef $Text_to_Cell) 
   Local Const $TCM_SETIMAGELIST = 0x1303 
   $hImageList = ImageList_Create($hImageList) 
   GUICtrlSendMsg($nCtrl, $TCM_SETIMAGELIST, 0, $hImageList) 
    
   Local $szIconFile = "shell32.dll" 
    
   Local $tcitem = DllStructCreate("uint;dword;dword;ptr;int;int;int") 
   DllStructSetData($tcitem, 1, 0x0002) 
   DllStructSetData($tcitem, 6, 0) 
   AddImageToTab($main_GUI, $nCtrl, $hImageList, 0, $tcitem, $szIconFile, 12) 
    
   DllStructSetData($tcitem, 6, 1) 
   AddImageToTab($main_GUI, $nCtrl, $hImageList, 1, $tcitem, $szIconFile, 160) 
    
   DllStructSetData($tcitem, 6, 2) 
   If $Address_Book = 1 Then AddImageToTab($main_GUI, $nCtrl, $hImageList, 2, $tcitem, $szIconFile, 21) 
    
   DllStructSetData($tcitem, 6, 3) 
   If $Text_to_Cell = 1 Then AddImageToTab($main_GUI, $nCtrl, $hImageList, 3, $tcitem, $szIconFile, 200) 
    
   DllStructDelete($tcitem) 
EndFunc  ;==>Bind_ImageList 

Func AddImageToTab(ByRef $main_GUI, ByRef $nCtrl, ByRef $hImageList, $nTabIndex, ByRef $nItem, ByRef $szIconFile, $nIconID) 
   Local Const $TCM_SETITEM = 0x1306 
   Local $hIcon = DllStructCreate("int") 
   Local $result = DllCall("shell32.dll", "int", "ExtractIconEx", "str", $szIconFile, "int", $nIconID, "hwnd", 0, "ptr", DllStructGetPtr($hIcon), "int", 1) 
   $result = $result[0] 
   If $result > 0 Then 
      DllCall("comctl32.dll", "int", "ImageList_AddIcon", "hwnd", $hImageList, "hwnd", DllStructGetData($hIcon, 1)) 
      DllCall("user32.dll", "int", "SendMessage", "hwnd", ControlGetHandle($main_GUI, "", $nCtrl), "int", $TCM_SETITEM, "int", $nTabIndex, "ptr", DllStructGetPtr($nItem)) 
      DllCall("user32.dll", "int", "DestroyIcon", "hwnd", $hIcon) 
   EndIf 
    
   DllStructDelete($hIcon) 
EndFunc  ;==>AddImageToTab 

; ------------------------------------- Initialization Functions --------------------------------------- 

Func Initilaize(ByRef $initial_view, ByRef $Address_Book, ByRef $Text_to_Cell, ByRef $online_view, ByRef $Address_info) 
   _ReadINI($initial_view, $Address_Book, $Text_to_Cell, $online_view, $Address_info) 
  ; check who is online ? 
  ; feed info to controls 
EndFunc  ;==>Initilaize 

Func help_center() 
  ; as an idea only 
   Local $PID = Run(@ProgramFilesDir & "\Internet Explorer\iexplore.exe http://www.xpcleanmenu.hostrocket.com/Help%20Center/help.html") 
EndFunc  ;==>help_center 

Func set_view(ByRef $initial_view, ByRef $child1, ByRef $child2, ByRef $child3A, ByRef $child3B, ByRef $child4, _ 
      ByRef $main_tab, ByRef $child1_tab, ByRef $child2_view, ByRef $_simple, ByRef $view_button, ByRef $main_tabitem1) 
   Local $child2_read 
  ; initial view and Simple/Advanced button 
   If $initial_view = 0 Then 
      GUISetState(@SW_HIDE, $child1) 
      GUISetState(@SW_HIDE, $child3A) 
      GUISetState(@SW_HIDE, $child2) 
      GUISetState(@SW_HIDE, $child4) 
      GUICtrlSetState($child1_tab, $GUI_HIDE) 
      GUICtrlSetState($main_tab, $GUI_HIDE) 
      $child2_read = GUICtrlRead($child2_view) 
      GUICtrlSetData($_simple, $child2_read) 
      GUICtrlSetState($_simple, $GUI_SHOW + $GUI_ENABLE) 
      GUICtrlSetData($view_button, "A&dvanced") 
      $initial_view = 1 
      Return 
   EndIf 
    
   If $initial_view = 1 Then 
      GUICtrlSetState($_simple, $GUI_HIDE) 
      GUICtrlSetState($main_tab, $GUI_SHOW) 
      GUICtrlSetState($main_tabitem1, $GUI_SHOW) 
      GUICtrlSetState($child1_tab, $GUI_SHOW) 
      GUISetState(@SW_HIDE, $child4) 
      GUISetState(@SW_SHOW, $child2) 
      GUISetState(@SW_SHOW, $child3B) 
      GUISetState(@SW_HIDE, $child3A) 
      GUISetState(@SW_HIDE, $child1) 
      GUISwitch($child2); -------------------------------- NEED THIS TAB/GUI to get Focus??????????? help 
      GUISetState(@SW_SHOW, $child2) 
      GUICtrlSetState($child2_view, $GUI_FOCUS) 
      $child2_read = GUICtrlRead($_simple) 
      GUICtrlSetData($child2_view, $child2_read) 
      GUICtrlSetData($view_button, "&Simple") 
      $initial_view = 0 
      Return 
   EndIf 
EndFunc  ;==>set_view 

Func _ReadINI(ByRef $initial_view, ByRef $Address_Book, ByRef $Text_to_Cell, ByRef $online_view, ByRef $Address_info) 
  ; set gui initial view - 0 = Simple, 1 = Advanced 
   $initial_view = Int(IniRead(@ScriptDir & '\ChatClient.ini', "DEVELOPERS SETTINGS", "initial_view", 0)) 
  ; to show *Address Book* and *Text to Cell* Advanced tab number three and four - 1 = Show, 0 = No Show 
   $Address_Book = Int(IniRead(@ScriptDir & '\ChatClient.ini', "DEVELOPERS SETTINGS", "Address_Book", 0)) 
   $Text_to_Cell = Int(IniRead(@ScriptDir & '\ChatClient.ini', "DEVELOPERS SETTINGS", "Text_to_Cell", 0)) 
  ; show - who's on line GUI - 1 = Show, 0 = No Show 
   $online_view = Int(IniRead(@ScriptDir & '\ChatClient.ini', "DEVELOPERS SETTINGS", "online_view", 1)) 
  ;$Address_info = IniReadSection(@ScriptDir & '\ChatClient.ini',"Address Book") 
    
EndFunc  ;==>_ReadINI 

Func _ReduceMemory() 
   Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) 
   Return $ai_Return[0] 
EndFunc  ;==>_ReduceMemory 

;--------------------------------------- INI Functions ----------------------------------------------------

Func set_group()
    
    Local $group_info, $Address_info 
    
;populates group view
    $group_info = GUICtrlRead($child3A_combo1)
    If $group_info = "" Then
        MsgBox(64,"Gruop View Error", "Please Select a Group Name First  ")
        Return
    EndIf
    $Address_info = IniReadSection(@ScriptDir & '\ChatClient.ini',$group_info)
    If @error =1 Then
        MsgBox(64,"Gruop View Error #1", "Section Not Found  ")
        Return
    EndIf
    If @error =2 Then
        MsgBox(64,"Gruop View Error #2", "The Section was Empty or Incorrect Format  ")
        Return
    EndIf
    GUICtrlSetData($listview,(GUICtrlSetData($listview,"")))
    For $x = 1 To $Address_info[0][0] 
      GUICtrlCreateListViewItem($Address_info[$x][1], $listview) 
    Next 
EndFunc

;--------------------------------------- Developers TCP Functions ------------------------------------------ 

Func send_message(ByRef $send_info) 
  ; example 
   MsgBox(0, "Test", "This message to be replaced by Developers TCP Send   " & @CRLF & "The Message is:  " & @CRLF & $send_info) 
EndFunc  ;==>send_message

8)

NEWHeader1.png

Link to comment
Share on other sites

me and my dumb-butt

forgot this

[DEVELOPERS SETTINGS] 
# set gui initial view - 0 = Simple, 1 = Advanced 
initial_view = 1 

# to show *Address Book* and *Text to Cell* Advanced tab number three and four - 1 = Show, 0 = No Show 
Address_Book = 1 
Text_to_Cell = 1 

# show - who's on line GUI - 1 = Show, 0 = No Show 
online_view = 1 

[Autoit] 
key_1=Dod|BigDod|Cell
key_2=Gary|gafrost|Cell 
key_3=Robert|Valuater|Cell 

[Family]
key_1=Dadsname|dad.com|No
key_2=Momsname|mom.net|Yes
Key-3=Bother|bother@msn|Yes

[Friends] 
Key_1=Dave|website|cell
Key_2=Dan|website|cell
Key_3=Debbie|website|cell
Key_4=Doug|website|cell

8)

NEWHeader1.png

Link to comment
Share on other sites

Due to the fact that each section could have a different number of keys, it would be best to delete all items then populate:

; Includes
#include <GUIConstants.au3>
#include <GuiListView.au3>

#region **** install files if needed ****
If @Compiled Then
    If Not FileExists(@ScriptDir & '\ChatClient.ini') Then FileInstall("c:\AutoitITS\ChatClient.ini", @ScriptDir & '\ChatClient.ini')
EndIf
#endregion **** end install files if needed ****

_Main()

#region --- _Main Function ---
Func _Main()
    opt('MustDeclareVars', 1)
    #region --- DEVELOPERS SETTINGS ---
;********************************************************
;DEVELOPERS SETTINGS
    Local $initial_view, $Address_Book, $Text_to_Cell, $online_view, $Address_info
; END DEVELOPER SETTINGS
;********************************************************
    #endregion --- END DEVELOPER SETTINGS ---
    Local $hide_button, $show_button, $online_list
    
    #region ---- GUI Variables Declarations ----
    Local $hImageList = 0, $Config_INI = @ScriptDir & '\ChatClient.ini'
    Local $Address_INI = @ScriptDir & '\AddressBook.ini'
    
    Local $main_GUI, $send_box, $send_button, $_simple, $view_button, $help_button, $cancel_button, $listview
    Local $display, $msg, $btn_msg, $send_info, $tabidx, $x
    Local $child1, $child1_tab, $child1_tabitem1, $child1_tabitem2, $child1_tabitem3
    Local $child2, $child2_view
    Local $child3A, $child3B, $child3A_tab, $child3A_tabitem1, $child3A_tabitem2, $child3A_combo1
    Local $child3A_button1, $child3A_label1A, $child3A_button1A
    Local $child4, $child4_view, $child4_input, $child4_button
    Local $main_tab, $main_tabitem1, $main_tabitem2, $main_tabitem3, $main_tabitem4
; set up functions
    Initilaize($Config_INI, $initial_view, $Address_Book, $Text_to_Cell, $online_view, $Address_info)
    
    #endregion ---- END GUI Variables Declarations ----
    $main_GUI = GUICreate("Autoit-ITS   Connection Center", 400, 360, -1, -1);, BitOr($GUI_SS_DEFAULT_GUI,$WS_CLIPSIBLINGS))
; create send text
    $send_box = GUICtrlCreateEdit("Type your text here", 10, 260, 300, 60)
    $send_button = GUICtrlCreateButton("S&end", 320, 278, 70, 30)
    GUICtrlSetState(-1, $GUI_DEFBUTTON)
    
; creates edit for simple view
    $_simple = GUICtrlCreateEdit("Your last text conversation", 15, 40, 370, 215)
    GUICtrlSetState(-1, $GUI_HIDE)
    
; create control buttons
    $view_button = GUICtrlCreateButton("&Simple", 20, 330, 70, 20)
    If $online_view = 1 Then $show_button = GUICtrlCreateButton("S&how List", 120, 330, 70, 20)
    $help_button = GUICtrlCreateButton("&Help", 220, 330, 70, 20)
    $cancel_button = GUICtrlCreateButton("&Cancel", 320, 330, 70, 20)
    GUISetState()
    
    
; Creates the first child window that is implemented into the main GUI
    $child1 = GUICreate("", 370, 215, 15, 40, BitOR($WS_CHILD, $WS_TABSTOP), -1, $main_GUI)
;GUISetBkColor(0x257788); just for dimensing the child
    $child1_tab = GUICtrlCreateTab(0, 0, 370, 215)
    $child1_tabitem1 = GUICtrlCreateTabItem("Connections")
    $child1_tabitem2 = GUICtrlCreateTabItem("Administration")
    $child1_tabitem3 = GUICtrlCreateTabItem("Options")
    GUICtrlCreateTabItem("")
    GUISetState(@SW_HIDE)
    
; create chat view text
    $child2 = GUICreate("", 370, 215, 15, 40, BitOR($WS_CHILD, $WS_TABSTOP), -1, $main_GUI)
    $child2_view = GUICtrlCreateEdit("Your last text conversation", 0, 0, 370, 215)
    GUISetState(@SW_HIDE)
    
    
; Creates the second child window that is implemented into the main GUI
    $child3A = GUICreate("", 370, 215, 15, 40, BitOR($WS_CHILD, $WS_TABSTOP), -1, $main_GUI)
;GUISetBkColor(0x257788); just for dimensing the child
    
    $child3B = GUICreate("", 210, 220, 158, 0, BitOR($WS_CHILD, $WS_TABSTOP), -1, $child3A)
;GUISetBkColor(0x257788)
    $listview = GUICtrlCreateListView("Name|Screen Name|Member", 0, 2, 210, 211, BitOR($LVS_NOSORTHEADER, $LVS_SHOWSELALWAYS, $WS_TABSTOP), $WS_EX_CLIENTEDGE)
;~     For $x = 1 To $Address_info[0][0]
;~         GUICtrlCreateListViewItem($Address_info[$x][1], $listview)
;~     Next
    GUISetState(@SW_HIDE)
    
; create chat view text
    $child4 = GUICreate("", 370, 215, 15, 40, BitOR($WS_CHILD, $WS_TABSTOP), -1, $main_GUI)
    $child4_view = GUICtrlCreateEdit("Your last Text to Cell Phone", 0, 0, 370, 150)
    $child4_input = GUICtrlCreateInput("Cell Number", 20, 170, 200, 20)
    $child4_button = GUICtrlCreateButton("&Connect", 250, 168, 70, 25)
    GUISetState(@SW_HIDE)
    
    GUISwitch($child3A)
    $child3A_tab = GUICtrlCreateTab(0, 0, 156, 215)
    $child3A_tabitem1 = GUICtrlCreateTabItem("Group View")
    GUICtrlCreateLabel("Choose a Group to View", 15, 35, 125, 20)
    $child3A_combo1 = GUICtrlCreateCombo("", 15, 55, 120, 20)
    GUICtrlSetData(-1, "Autoit|Family|Friends|Personal|Business|Associates|Classmates")
    $child3A_button1 = GUICtrlCreateButton("S&elect", 40, 90, 70, 20)
    GUICtrlCreateLabel("Name to Send Text", 25, 130, 125, 20)
    $child3A_label1A = GUICtrlCreateLabel("Select from Group List", 15, 150, 120, 20, $SS_SUNKEN + $SS_CENTER)
    $child3A_button1A = GUICtrlCreateButton("Se&lect", 40, 180, 70, 20)
    $child3A_tabitem2 = GUICtrlCreateTabItem("Name View")
    GUICtrlCreateTabItem("")
    
; Switch back the main GUI and create the tabs
    GUISwitch($main_GUI)
    $main_tab = GUICtrlCreateTab(10, 10, 380, 250)
    $main_tabitem1 = GUICtrlCreateTabItem("Controls")
    $main_tabitem2 = GUICtrlCreateTabItem("Chat View")
    If $Address_Book = 1 Then $main_tabitem3 = GUICtrlCreateTabItem("Address Book")
    If $Text_to_Cell = 1 Then $main_tabitem4 = GUICtrlCreateTabItem("Text to Cell")
    GUICtrlCreateTabItem("")
    GUICtrlSetState($main_tabitem1, $GUI_HIDE)
    
    Bind_ImageList($main_GUI, $main_tab, $hImageList, $Address_Book, $Text_to_Cell)
    
; create a who is online list
    $online_list = GUICreate("Autoit-ITS   Online Center", 210, 340, 10, 10)
; create list display
    $display = GUICtrlCreateEdit("Who's - Online", 10, 10, 190, 280)
    If $online_view = 1 Then $hide_button = GUICtrlCreateButton("H&ide List", 70, 310, 70, 20)
    GUISetState(@SW_HIDE, $online_list)
    
    
    set_view($initial_view, $child1, $child2, $child3A, $child3B, $child4, $main_tab, $child1_tab, $child2_view, _
            $_simple, $view_button, $main_tabitem1)
    _ReduceMemory()
    While 1
        $msg = GUIGetMsg(1)
        Select
            Case $msg[0] = $GUI_EVENT_CLOSE Or $msg[0] = $cancel_button
                ExitLoop
            Case $msg[0] = $hide_button
                GUISetState(@SW_HIDE, $online_list)
                GUICtrlSetData($show_button, "S&how List")
            Case $msg[0] = $show_button
                $btn_msg = GUICtrlRead($show_button)
                If $btn_msg = "H&ide List" Then
                    GUISetState(@SW_HIDE, $online_list)
                    GUICtrlSetData($show_button, "S&how List")
                Else
                    GUISetState(@SW_SHOW, $online_list)
                    GUICtrlSetData($show_button, "H&ide List")
                EndIf
            Case $msg[0] = $help_button
                help_center()
            Case $msg[0] = $view_button
                set_view($initial_view, $child1, $child2, $child3A, $child3B, $child4, $main_tab, $child1_tab, $child2_view, _
                        $_simple, $view_button, $main_tabitem1)
            Case $msg[0] = $send_button
                $send_info = GUICtrlRead($send_box)
                If $send_info <> "" Then
                    GUICtrlSetData($_simple, @CRLF & $send_info, -1)
                    GUICtrlSetData($child2_view, @CRLF & $send_info, -1)
                    send_message($send_info)
                EndIf
            Case $msg[0] = $child3A_button1
                set_group($child3A_combo1, $listview, $Address_INI)
            Case $msg[0] = $main_tab
                $tabidx = GUICtrlRead($main_tab)
                Select
                    Case $tabidx = 0
                        GUISetState(@SW_HIDE, $child4)
                        GUISetState(@SW_HIDE, $child2)
                        GUISetState(@SW_HIDE, $child3A)
                        GUISetState(@SW_SHOW, $child1)
                        
                    Case $tabidx = 1
                        GUISetState(@SW_HIDE, $child4)
                        GUISetState(@SW_HIDE, $child3A)
                        GUISetState(@SW_HIDE, $child1)
                        GUISetState(@SW_SHOW, $child2)
                        
                    Case $tabidx = 2
                        GUISetState(@SW_HIDE, $child4)
                        GUISetState(@SW_SHOW, $child3A)
                        GUISetState(@SW_HIDE, $child2)
                        GUISetState(@SW_HIDE, $child1)
                    Case $tabidx = 3
                        GUISetState(@SW_SHOW, $child4)
                        GUISetState(@SW_HIDE, $child2)
                        GUISetState(@SW_HIDE, $child3A)
                        GUISetState(@SW_HIDE, $child1)
                EndSelect
        EndSelect
    WEnd
    
    DllCall("comctl32.dll", "int", "ImageList_Destroy", "hwnd", $hImageList)
    Exit
EndFunc  ;==>_Main
#endregion --- END _Main Function ---
;-------------------------------------- GUI Functions --------------------------------------

Func ImageList_Create(ByRef $hImageList)
    $hImageList = DllCall("comctl32.dll", "hwnd", "ImageList_Create", "int", 16, "int", 16, "int", 0x0021, "int", 0, "int", 1)
    $hImageList = $hImageList[0]
    Return $hImageList
EndFunc  ;==>ImageList_Create

Func Bind_ImageList(ByRef $main_GUI, ByRef $nCtrl, ByRef $hImageList, ByRef $Address_Book, ByRef $Text_to_Cell)
    Local Const $TCM_SETIMAGELIST = 0x1303
    $hImageList = ImageList_Create($hImageList)
    GUICtrlSendMsg($nCtrl, $TCM_SETIMAGELIST, 0, $hImageList)
    
    Local $szIconFile = "shell32.dll"
    
    Local $tcitem = DllStructCreate("uint;dword;dword;ptr;int;int;int")
    DllStructSetData($tcitem, 1, 0x0002)
    DllStructSetData($tcitem, 6, 0)
    AddImageToTab($main_GUI, $nCtrl, $hImageList, 0, $tcitem, $szIconFile, 12)
    
    DllStructSetData($tcitem, 6, 1)
    AddImageToTab($main_GUI, $nCtrl, $hImageList, 1, $tcitem, $szIconFile, 160)
    
    DllStructSetData($tcitem, 6, 2)
    If $Address_Book = 1 Then AddImageToTab($main_GUI, $nCtrl, $hImageList, 2, $tcitem, $szIconFile, 21)
    
    DllStructSetData($tcitem, 6, 3)
    If $Text_to_Cell = 1 Then AddImageToTab($main_GUI, $nCtrl, $hImageList, 3, $tcitem, $szIconFile, 200)
    
    DllStructDelete($tcitem)
EndFunc  ;==>Bind_ImageList

Func AddImageToTab(ByRef $main_GUI, ByRef $nCtrl, ByRef $hImageList, $nTabIndex, ByRef $nItem, ByRef $szIconFile, $nIconID)
    Local Const $TCM_SETITEM = 0x1306
    Local $hIcon = DllStructCreate("int")
    Local $result = DllCall("shell32.dll", "int", "ExtractIconEx", "str", $szIconFile, "int", $nIconID, "hwnd", 0, "ptr", DllStructGetPtr($hIcon), "int", 1)
    $result = $result[0]
    If $result > 0 Then
        DllCall("comctl32.dll", "int", "ImageList_AddIcon", "hwnd", $hImageList, "hwnd", DllStructGetData($hIcon, 1))
        DllCall("user32.dll", "int", "SendMessage", "hwnd", ControlGetHandle($main_GUI, "", $nCtrl), "int", $TCM_SETITEM, "int", $nTabIndex, "ptr", DllStructGetPtr($nItem))
        DllCall("user32.dll", "int", "DestroyIcon", "hwnd", $hIcon)
    EndIf
    
    DllStructDelete($hIcon)
EndFunc  ;==>AddImageToTab

; ------------------------------------- Initialization Functions ---------------------------------------

Func Initilaize(ByRef $Config_INI, ByRef $initial_view, ByRef $Address_Book, ByRef $Text_to_Cell, ByRef $online_view, ByRef $Address_info)
    _ReadINI($Config_INI, $initial_view, $Address_Book, $Text_to_Cell, $online_view, $Address_info)
; check who is online ?
; feed info to controls
EndFunc  ;==>Initilaize

Func help_center()
; as an idea only
    Local $PID = Run(@ProgramFilesDir & "\Internet Explorer\iexplore.exe http://www.xpcleanmenu.hostrocket.com/Help%20Center/help.html")
EndFunc  ;==>help_center

Func set_view(ByRef $initial_view, ByRef $child1, ByRef $child2, ByRef $child3A, ByRef $child3B, ByRef $child4, _
        ByRef $main_tab, ByRef $child1_tab, ByRef $child2_view, ByRef $_simple, ByRef $view_button, ByRef $main_tabitem1)
    Local $child2_read
; initial view and Simple/Advanced button
    If $initial_view = 0 Then
        GUISetState(@SW_HIDE, $child1)
        GUISetState(@SW_HIDE, $child3A)
        GUISetState(@SW_HIDE, $child2)
        GUISetState(@SW_HIDE, $child4)
        GUICtrlSetState($child1_tab, $GUI_HIDE)
        GUICtrlSetState($main_tab, $GUI_HIDE)
        $child2_read = GUICtrlRead($child2_view)
        GUICtrlSetData($_simple, $child2_read)
        GUICtrlSetState($_simple, $GUI_SHOW + $GUI_ENABLE)
        GUICtrlSetData($view_button, "A&dvanced")
        $initial_view = 1
        Return
    EndIf
    
    If $initial_view = 1 Then
        GUICtrlSetState($_simple, $GUI_HIDE)
        GUICtrlSetState($main_tab, $GUI_SHOW)
        GUICtrlSetState($main_tabitem1, $GUI_SHOW)
        GUICtrlSetState($child1_tab, $GUI_SHOW)
        GUISetState(@SW_HIDE, $child4)
        GUISetState(@SW_SHOW, $child2)
        GUISetState(@SW_SHOW, $child3B)
        GUISetState(@SW_HIDE, $child3A)
        GUISetState(@SW_HIDE, $child1)
        GUISwitch($child2); -------------------------------- NEED THIS TAB/GUI to get Focus??????????? help
        GUISetState(@SW_SHOW, $child2)
        GUICtrlSetState($child2_view, $GUI_FOCUS)
        $child2_read = GUICtrlRead($_simple)
        GUICtrlSetData($child2_view, $child2_read)
        GUICtrlSetData($view_button, "&Simple")
        $initial_view = 0
        Return
    EndIf
EndFunc  ;==>set_view

Func _ReadINI(ByRef $Config_INI, ByRef $initial_view, ByRef $Address_Book, ByRef $Text_to_Cell, ByRef $online_view, ByRef $Address_info)
; set gui initial view - 0 = Simple, 1 = Advanced
    $initial_view = Int(IniRead($Config_INI, "DEVELOPERS SETTINGS", "initial_view", 0))
; to show *Address Book* and *Text to Cell* Advanced tab number three and four - 1 = Show, 0 = No Show
    $Address_Book = Int(IniRead($Config_INI, "DEVELOPERS SETTINGS", "Address_Book", 0))
    $Text_to_Cell = Int(IniRead($Config_INI, "DEVELOPERS SETTINGS", "Text_to_Cell", 0))
; show - who's on line GUI - 1 = Show, 0 = No Show
    $online_view = Int(IniRead($Config_INI, "DEVELOPERS SETTINGS", "online_view", 1))
    
EndFunc  ;==>_ReadINI

Func set_group(ByRef $child3A_combo1, ByRef $listview, ByRef $Address_INI)
    
    Local $group_info, $Address_info
    
;populates group view
    $group_info = GUICtrlRead($child3A_combo1)
    If $group_info = "" Then
        MsgBox(64, "Gruop View Error", "Please Select a Group Name First  ")
        Return
    EndIf
    $Address_info = IniReadSection($Address_INI, $group_info)
    If @error = 1 Then
        MsgBox(64, "Gruop View Error #1", "Section Not Found  ")
        Return
    EndIf
    If @error = 2 Then
        MsgBox(64, "Gruop View Error #2", "The Section was Empty or Incorrect Format  ")
        Return
    EndIf
    _GUICtrlListViewDeleteAllItems ($listview)
    For $x = 1 To $Address_info[0][0]
        GUICtrlCreateListViewItem($Address_info[$x][1], $listview)
    Next
EndFunc  ;==>set_group

Func _ReduceMemory()
    Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    Return $ai_Return[0]
EndFunc  ;==>_ReduceMemory

;--------------------------------------- Developers TCP Functions ------------------------------------------

Func send_message(ByRef $send_info)
; example
    MsgBox(0, "Test", "This message to be replaced by Developers TCP Send   " & @CRLF & "The Message is:  " & @CRLF & $send_info)
EndFunc  ;==>send_message

ChatClient.ini

[DEVELOPERS SETTINGS]
# set gui initial view - 0 = Simple, 1 = Advanced
initial_view = 1

# to show *Address Book* and *Text to Cell* Advanced tab number three and four - 1 = Show, 0 = No Show
Address_Book = 1
Text_to_Cell = 1

# show - who's on line GUI - 1 = Show, 0 = No Show
online_view = 1

AddressBook.ini

[Autoit] 
key_1=Dod|BigDod|Cell
key_2=Gary|gafrost|Cell 
key_3=Robert|Valuater|Cell 

[Family]
key_1=Dadsname|dad.com|No
key_2=Momsname|mom.net|Yes
Key-3=Bother|bother@msn|Yes

[Friends] 
Key_1=Dave|website|cell
Key_2=Dan|website|cell
Key_3=Debbie|website|cell
Key_4=Doug|website|cell
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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