au3scr Posted March 8, 2008 Posted March 8, 2008 hi How to make button that refreshes the list? or is it possible to refresh list automatically? expandcollapse popup#include <GUIConstants.au3> #include <guilistview.au3> $var = WinList() #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 633, 500, 193, 115) $List1 = GUICtrlCreateListView("windows ", 10, 10, 600, 400) Dim $list2[$var[0][0] + 1] For $i = 1 To $var[0][0] If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then $list2[$i] = GUICtrlCreateListViewItem($var[$i][0], $List1) GUISetState(@SW_SHOW) EndIf Next $edit1 = GUICtrlCreateEdit('',20,420,400,40) GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") $button1 = GUICtrlCreateButton ("minimize",20,460,75,15) $button2 = GUICtrlCreateButton ("restore",20 + 75,460,75,15) $button2 = GUICtrlCreateButton ("refresh",20 + 75 * 2,460,75,15) Func IsVisible($handle) If BitAND(WinGetState($handle), 2) Then Return 1 Else Return 0 EndIf EndFunc ;==>IsVisible While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $List1 ConsoleWrite("list1 clicked" & @CRLF) Case $button1 minimize () Case $button2 restore () EndSwitch WEnd Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) If ControlGetFocus('Testing') <> 'Edit1' Then #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) Select Case $wParam = $List1 Select Case $event = $NM_CLICK Local $tagNMITEMACTIVATE = DllStructCreate("int;int;int;int;int;int;int;int;int", $lParam) $selected = DllStructGetData($tagNMITEMACTIVATE, 4) $selcol = DllStructGetData($tagNMITEMACTIVATE, 5) $seltxt = StringSplit(GUICtrlRead(GUICtrlRead($List1)),'|') GUICtrlSetData($Edit1, $seltxt[1 + $selcol]) EndSelect EndSelect Return $GUI_RUNDEFMSG EndIF EndFunc ;==>WM_Notify_Events func minimize () $windowToMinimize = GUICtrlRead ($edit1) $winminimize = $windowToMinimize WinSetState($winminimize ,"",@SW_MINIMIZE) EndFunc func restore () $windowToRestore = GUICtrlRead ($edit1) $winrestore = $windowToRestore WinSetState($winrestore ,"",@SW_RESTORE) EndFunc
Kip Posted March 8, 2008 Posted March 8, 2008 AdlibEnable: expandcollapse popup#include <GUIConstants.au3> #include <guilistview.au3> AdlibEnable("_Refresh") #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 633, 500, 193, 115) $List1 = GUICtrlCreateListView("windows ", 10, 10, 600, 400) $List1 = GUICtrlGetHandle($List1) $edit1 = GUICtrlCreateEdit('',20,420,400,40) GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") $button1 = GUICtrlCreateButton ("minimize",20,460,75,15) $button2 = GUICtrlCreateButton ("restore",20 + 75,460,75,15) $button2 = GUICtrlCreateButton ("refresh",20 + 75 * 2,460,75,15) GUISetState(@SW_SHOW) _Refresh() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $List1 ConsoleWrite("list1 clicked" & @CRLF) Case $button1 minimize () Case $button2 restore () EndSwitch WEnd Func _Refresh() $var = WinList() _GUICtrlListView_DeleteAllItems($List1) Dim $list2[$var[0][0] + 1] For $i = 1 To $var[0][0] If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then _GUICtrlListView_AddItem($List1,$var[$i][0]) EndIf Next EndFunc Func IsVisible($handle) If BitAND(WinGetState($handle), 2) Then Return 1 Else Return 0 EndIf EndFunc ;==>IsVisible Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) If ControlGetFocus('Testing') <> 'Edit1' Then #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) Select Case $wParam = $List1 Select Case $event = $NM_CLICK Local $tagNMITEMACTIVATE = DllStructCreate("int;int;int;int;int;int;int;int;int", $lParam) $selected = DllStructGetData($tagNMITEMACTIVATE, 4) $selcol = DllStructGetData($tagNMITEMACTIVATE, 5) $seltxt = StringSplit(GUICtrlRead(GUICtrlRead($List1)),'|') GUICtrlSetData($Edit1, $seltxt[1 + $selcol]) EndSelect EndSelect Return $GUI_RUNDEFMSG EndIF EndFunc ;==>WM_Notify_Events func minimize () $windowToMinimize = GUICtrlRead ($edit1) $winminimize = $windowToMinimize WinSetState($winminimize ,"",@SW_MINIMIZE) EndFunc func restore () $windowToRestore = GUICtrlRead ($edit1) $winrestore = $windowToRestore WinSetState($winrestore ,"",@SW_RESTORE) EndFunc MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
ByteMyCookies Posted March 8, 2008 Posted March 8, 2008 Or if you dont want it to refresh constantly, so you can accually click on a list item use this. Btw you had $Button2 definede twice, so the restore button was accually being changed to the refresh button. expandcollapse popup#include <GUIConstants.au3> #include <guilistview.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 633, 500, 193, 115) $List1 = GUICtrlCreateListView("windows ", 10, 10, 600, 400) $List1 = GUICtrlGetHandle($List1) $edit1 = GUICtrlCreateEdit('', 20, 420, 400, 40) GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") $button1 = GUICtrlCreateButton("minimize", 20, 460, 75, 15) $button2 = GUICtrlCreateButton("restore", 20 + 75, 460, 75, 15) $button3 = GUICtrlCreateButton("refresh", 20 + 75 * 2, 460, 75, 15) GUISetState(@SW_SHOW) _Refresh() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $List1 ConsoleWrite("list1 clicked" & @CRLF) Case $button1 minimize() Case $button2 restore() Case $button3 refresh() EndSwitch WEnd Func IsVisible($handle) If BitAND(WinGetState($handle), 2) Then Return 1 Else Return 0 EndIf EndFunc ;==>IsVisible Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) If ControlGetFocus('Testing') <> 'Edit1' Then #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) Select Case $wParam = $List1 Select Case $event = $NM_CLICK Local $tagNMITEMACTIVATE = DllStructCreate("int;int;int;int;int;int;int;int;int", $lParam) $selected = DllStructGetData($tagNMITEMACTIVATE, 4) $selcol = DllStructGetData($tagNMITEMACTIVATE, 5) $seltxt = StringSplit(GUICtrlRead(GUICtrlRead($List1)), '|') GUICtrlSetData($edit1, $seltxt[1 + $selcol]) EndSelect EndSelect Return $GUI_RUNDEFMSG EndIf EndFunc ;==>WM_Notify_Events Func minimize() $windowToMinimize = GUICtrlRead($edit1) $winminimize = $windowToMinimize WinSetState($winminimize, "", @SW_MINIMIZE) EndFunc ;==>minimize Func restore() $windowToRestore = GUICtrlRead($edit1) $winrestore = $windowToRestore WinSetState($winrestore, "", @SW_RESTORE) EndFunc ;==>restore Func refresh() $var = WinList() _GUICtrlListView_DeleteAllItems($List1) Dim $list2[$var[0][0] + 1] For $i = 1 To $var[0][0] If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then _GUICtrlListView_AddItem($List1, $var[$i][0]) EndIf Next EndFunc ;==>refresh My Scripts,[topic="65986"]AI Example[/topic] ,Capable of Emotion!
au3scr Posted March 8, 2008 Author Posted March 8, 2008 After refresh i cant use minimize and maximize function
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now