yucatan Posted July 10, 2008 Share Posted July 10, 2008 is ut possble to use a GUICtrlCreateList clickable so that when i click on the item on the first rule that he excutes some code then is that posseble ? Link to comment Share on other sites More sharing options...
Valuater Posted July 10, 2008 Share Posted July 10, 2008 Yes.... #include <GUIConstantsEx.au3> Local $MESSAGE = "notepad.exe|explorer.exe" GUICreate("My GUI list") ; will create a dialog box that when displayed is centered $mylist = GUICtrlCreateList("", 176, 32, 121, 97) GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling GUICtrlSetData(-1, $MESSAGE) $close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25) GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() If $msg = $mylist Then Run(GUICtrlRead($mylist)) EndIf If $msg = $close Then MsgBox(0, "", "the closing button has been clicked", 2) Exit EndIf WEnd 8) Link to comment Share on other sites More sharing options...
yucatan Posted July 10, 2008 Author Share Posted July 10, 2008 Yes.... #include <GUIConstantsEx.au3> Local $MESSAGE = "notepad.exe|explorer.exe" GUICreate("My GUI list") ; will create a dialog box that when displayed is centered $mylist = GUICtrlCreateList("", 176, 32, 121, 97) GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling GUICtrlSetData(-1, $MESSAGE) $close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25) GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() If $msg = $mylist Then Run(GUICtrlRead($mylist)) EndIf If $msg = $close Then MsgBox(0, "", "the closing button has been clicked", 2) Exit EndIf WEnd 8) thx Link to comment Share on other sites More sharing options...
yucatan Posted August 27, 2008 Author Share Posted August 27, 2008 thxhi another question is tjhis olso posseble with GUICtrlCreateListview ????? with execly the same works but not a GUICtrlCreatelist but a GUICtrlCreateListview? Link to comment Share on other sites More sharing options...
rasim Posted August 27, 2008 Share Posted August 27, 2008 yucatanExample #1expandcollapse popup#include <GUIConstantsEx.au3> Opt("GuiOnEventMode", 1) GUICreate("My GUI ListView", 300, 200) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $mylist = GUICtrlCreateListView("Items|SubItems", 10, 10, 280, 180) For $i = 1 To 10 GUICtrlCreateListViewItem("Item " & $i & "|" & "SubItem " & $i, $mylist) GUICtrlSetOnEvent(-1, "_ItemEvent") Next GUISetState() While 1 Sleep(100) WEnd Func _ItemEvent() ConsoleWrite("!>" & GUICtrlRead(@GUI_CtrlId) & " is selected" & @LF) EndFunc Func _Exit() Exit EndFuncoÝ÷ Ù±1jje{oÛjëh×6#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> $hGui = GuiCreate("TestGui", 300, 200) $hListView = GUICtrlCreateListView("Item|Subitem", 10, 10, 280, 180) For $i = 1 To 10 GUICtrlCreateListViewItem("Item " & $i & "|" & "SubItem " & $i, $hListView) Next GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $hListView If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CLICK Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) Local $iItem = DllStructGetData($tInfo, "Item") If $iItem <> -1 Then ConsoleWrite("!> Click on item " & $iItem + 1 & @LF) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Link to comment Share on other sites More sharing options...
yucatan Posted August 27, 2008 Author Share Posted August 27, 2008 yucatan Example #1 expandcollapse popup#include <GUIConstantsEx.au3> Opt("GuiOnEventMode", 1) GUICreate("My GUI ListView", 300, 200) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $mylist = GUICtrlCreateListView("Items|SubItems", 10, 10, 280, 180) For $i = 1 To 10 GUICtrlCreateListViewItem("Item " & $i & "|" & "SubItem " & $i, $mylist) GUICtrlSetOnEvent(-1, "_ItemEvent") Next GUISetState() While 1 Sleep(100) WEnd Func _ItemEvent() ConsoleWrite("!>" & GUICtrlRead(@GUI_CtrlId) & " is selected" & @LF) EndFunc Func _Exit() Exit EndFuncoÝ÷ Ù±1jje{oÛjëh×6#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> $hGui = GuiCreate("TestGui", 300, 200) $hListView = GUICtrlCreateListView("Item|Subitem", 10, 10, 280, 180) For $i = 1 To 10 GUICtrlCreateListViewItem("Item " & $i & "|" & "SubItem " & $i, $hListView) Next GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $hListView If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CLICK Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) Local $iItem = DllStructGetData($tInfo, "Item") If $iItem <> -1 Then ConsoleWrite("!> Click on item " & $iItem + 1 & @LF) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc thx but this works on one click is it posseble to change it to 2 click that when i dubbleclick then it runs the code and that when it gets Selected as now it just is selected nothing more is that posseble? Link to comment Share on other sites More sharing options...
rasim Posted August 27, 2008 Share Posted August 27, 2008 expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> $hGui = GuiCreate("TestGui", 300, 200) $hListView = GUICtrlCreateListView("Item|Subitem", 10, 10, 280, 180) For $i = 1 To 10 GUICtrlCreateListViewItem("Item " & $i & "|" & "SubItem " & $i, $hListView) Next GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $hListView If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) Local $iItem = DllStructGetData($tInfo, "Item") If $iItem <> -1 Then ConsoleWrite("!> Click on item " & $iItem + 1 & @LF) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Link to comment Share on other sites More sharing options...
yucatan Posted August 27, 2008 Author Share Posted August 27, 2008 expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> $hGui = GuiCreate("TestGui", 300, 200) $hListView = GUICtrlCreateListView("Item|Subitem", 10, 10, 280, 180) For $i = 1 To 10 GUICtrlCreateListViewItem("Item " & $i & "|" & "SubItem " & $i, $hListView) Next GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $hListView If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) Local $iItem = DllStructGetData($tInfo, "Item") If $iItem <> -1 Then ConsoleWrite("!> Click on item " & $iItem + 1 & @LF) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc rasim and ofcourse the other peopel that helped me out you did a realy a good job thx alot Link to comment Share on other sites More sharing options...
yucatan Posted August 28, 2008 Author Share Posted August 28, 2008 rasim and ofcourse the other peopel that helped me out you did a realy a good job thx alot how do i need to add a button in this gui ? when i add a button with this code $button_zoek = GUICtrlCreateButton("Zoek", -1, 195, 60 ) and in the while 1/wend i did this While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop case $msg = $button_zoek zoek() EndSwitch WEnd i added the case $msg = $button_zoek zoek() in the func zoek is standing this func zoek() MsgBox(4096, "Test", "This box will time out in 10 seconds", 10) endfunc but when i run the code the msgbox already show up without i have clicked the Zoek Button... fix i can fix that that the msgbox show when i click the button? thats a func in my code but the problem is that when i run the gui Link to comment Share on other sites More sharing options...
rasim Posted August 28, 2008 Share Posted August 28, 2008 While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $button_zoek zoek() EndSwitch WEndHelp Link to comment Share on other sites More sharing options...
yucatan Posted September 30, 2008 Author Share Posted September 30, 2008 rasim and ofcourse the other peopel that helped me out you did a realy a good job thx alot hi here i have some code i have a gui that i need to dubbleclick then it shows me some data this is the code expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> $hGui = GuiCreate("TestGui", 300, 200) $hListView = GUICtrlCreateListView("Item|Subitem", 10, 10, 280, 180) For $i = 1 To 10 GUICtrlCreateListViewItem("Item " & $i & "|" & "SubItem " & $i, $hListView) Next GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $hListView If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) Local $iItem = DllStructGetData($tInfo, "Item") If $iItem <> -1 Then ConsoleWrite("!> Click on item " & $iItem + 1 & @LF) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc the only problem is that the place in my code where i enter my listview is already in a func and func's cant share $vars so from the func wm_notify i cant access my data in the listview is there a way to fix this ? Link to comment Share on other sites More sharing options...
SoulA Posted October 1, 2008 Share Posted October 1, 2008 you can make the variable a global variable? Link to comment Share on other sites More sharing options...
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