Sign in to follow this  
Followers 0
yucatan

GUICtrlCreateList

12 posts in this topic

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 ?

Share this post


Link to post
Share on other sites



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)


NEWHeader1.png

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

thx

hi another question is tjhis olso posseble with GUICtrlCreateListview ????? with execly the same works but not a GUICtrlCreatelist but a GUICtrlCreateListview

?

Share this post


Link to post
Share on other sites

yucatan

Example #1

#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

Share this post


Link to post
Share on other sites

yucatan

Example #1

#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?

Share this post


Link to post
Share on other sites

#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

Share this post


Link to post
Share on other sites

#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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

#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 ?

Share this post


Link to post
Share on other sites

you can make the variable a global variable?

Share this post


Link to post
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
Sign in to follow this  
Followers 0