Jump to content

Combo in a listviewitem


Recommended Posts

Hi,

Ive got a simple question about listview, i want a combobox inside a listviewitem so i can multiselect options or change the value.

Script:

#include <GUIConstantsEx.au3>

GUICreate("TEST", 500, 500)
$lv=GUICtrlCreateListView("Test1 | Test 2 | Test 3", 0, 10, 500, 400)
$additem=Guictrlcreatebutton("Add!", 10, 450, 100, 20)

GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $additem
            GUICtrlCreateListViewItem("Item1 "&"|"&" Item2 "&"|"&" Combo", $lv)
    EndSwitch
WEnd

Is it possible? i cant figure it out!

Thnx!

Link to comment
Share on other sites

  • Moderators

misterDee,

Is it possible?

Indeed it is - and here is a very rough demo with loads of room for improvement: :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <Misc.au3>

Opt("TrayIconDebug", 1)

; We use ESC to exit the temporary Combo
Opt("GUICloseOnESC", 0)

; Set flag to indicate double click in ListView
Global $fDblClk = False
; Declare global variables
Global $aLV_Click_Info, $hTmp_Combo = 0

; Open DLL for _IsPressed
$dll = DllOpen("user32.dll")

; Create GUI
$hGUI = GUICreate("Test", 400, 250)

$hListView = _GUICtrlListView_Create($hGUI, "Col 0|Col 1|Col 2", 10, 10, 242, 200)
_GUICtrlListView_AddItem($hListView, "Item 00",0)
_GUICtrlListView_AddSubItem($hListView, 0, "Item 01", 1)
_GUICtrlListView_AddSubItem($hListView, 0, "Item 02", 2)
_GUICtrlListView_AddItem($hListView, "Item 10",1)
_GUICtrlListView_AddItem($hListView, "Item 20",2)
_GUICtrlListView_AddItem($hListView, "Item 30",3)

GUISetState()

; Look for double clicks
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            DllClose($dll)
            Exit
    EndSwitch

    ; If a temporary combo exists
    If $hTmp_Combo <> 0 Then
        ; If ENTER pressed
        If _IsPressed("0D", $dll) Then
            ; Set label to edit content
            $sText = GUICtrlRead($hTmp_Combo)
            _GUICtrlListView_SetItemText($hListView, $aLV_Click_Info[0], $sText, $aLV_Click_Info[1])
            ; Delete temporary combo
            GUICtrlDelete($hTmp_combo)
            $hTmp_Combo = 0
            GUICtrlSetState($hListView, $GUI_ENABLE)
        EndIf
        ; If ESC pressed
        If _IsPressed("1B", $dll) Then
            ; Delete temporary combo
            GUICtrlDelete($hTmp_Combo)
            $hTmp_Combo = 0
            GUICtrlSetState($hListView, $GUI_ENABLE)
        EndIf
    EndIf

    ; If an item was double clicked
    If $fDblClk Then
        $fDblClk = False
        ; Delete an existing temporary combo
        GUICtrlDelete($hTmp_Combo)
        ; Get label position
        Switch $aLV_Click_Info[1]
            Case 0 ; On Item
                $aLV_Rect_Info = _GUICtrlListView_GetItemRect($hListView, $aLV_Click_Info[0], 2)
            Case Else ; On SubItem
                $aLV_Rect_Info = _GUICtrlListView_GetSubItemRect($hListView, $aLV_Click_Info[0], $aLV_Click_Info[1])
        EndSwitch
        ; Create temporary combo
        $hTmp_Combo = GUICtrlCreateCombo("", $aLV_Rect_Info[0] + 10, $aLV_Rect_Info[1] + 10, 100, $aLV_Rect_Info[3] - $aLV_Rect_Info[1])
        GUICtrlSetData($hTmp_Combo, "Tom|Dick|Harry")
        GUICtrlSetState($hListView, $GUI_DISABLE)
        GUICtrlSetState($hTmp_Combo, BitOR($GUI_FOCUS, $GUI_ONTOP))

    EndIf

WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)

    ; If a combo exists, return immediately
    If $hTmp_Combo <> 0 Then Return $GUI_RUNDEFMSG

    Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    If HWnd(DllStructGetData($tNMHDR, "hWndFrom")) = $hListView And DllStructGetData($tNMHDR, "Code") = $NM_DBLCLK Then
        $aLV_Click_Info = _GUICtrlListView_SubItemHitTest($hListView)
        ; As long as the click was on an item or subitem
        If $aLV_Click_Info[0] <> -1 Then $fDblClk = True
    EndIf
    Return $GUI_RUNDEFMSG

EndFunc

Doubleclick an item to get the combo displayed, press "Enter" to change the ListView data, press "Escape" to close the combo with no changes.

Have fun improving it and let us see the end result! :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

misterDee,

its not gonna work with 'guictrlcreatetab'

Of course it is! But you need to do a lot of the work that AutoIt ususally does for you - go and read the Tabs tutorial in the Wiki to find out why. :)

And here is the proof: :P

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#Include <GuiTab.au3>

#include <Misc.au3>

; We use ESC to exit the temporary Combo
Opt("GUICloseOnESC", 0)

; Set flag to indicate double click in ListView
Global $fDblClk = False
; Declare global variables
Global $aLV_Click_Info, $hTmp_Combo = 0

; Open DLL for _IsPressed
$dll = DllOpen("user32.dll")

$hGUI = GUICreate("Test", 500, 500)

$hTab = GUICtrlCreateTab(10, 10, 480, 480)

$hTab0 = GUICtrlCreateTabItem("Tab 0")

$hListView = _GUICtrlListView_Create($hGUI, "Col 0|Col 1|Col 2", 20, 40, 242, 200)
_GUICtrlListView_AddItem($hListView, "Item 00",0)
_GUICtrlListView_AddSubItem($hListView, 0, "Item 01", 1)
_GUICtrlListView_AddSubItem($hListView, 0, "Item 02", 2)
_GUICtrlListView_AddItem($hListView, "Item 10",1)
_GUICtrlListView_AddItem($hListView, "Item 20",2)
_GUICtrlListView_AddItem($hListView, "Item 30",3)

$hTab1 = GUICtrlCreateTabItem("Tab 1")

GUICtrlCreateTabItem("")    ; end tabitem definition

GUISetState()

; Look for double clicks
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

$iLastTab = 0

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            DllClose($dll)
            Exit
    EndSwitch
;#cs
    ; Check which Tab is active
    $iCurrTab = _GUICtrlTab_GetCurFocus($hTab)
    ; If the Tab has changed
    If $iCurrTab <> $iLastTab Then
        ; Store the value for future comparisons
        $iLastTab = $iCurrTab
        ; Show/Hide controls as required
        Switch $iCurrTab
            Case 0
                ControlShow($hGUI, "", $hListView)
                GUICtrlSetState($hTmp_Combo, $GUI_SHOW)
            Case 1
                ControlHide($hGUI, "", $hListView)
                GUICtrlSetState($hTmp_Combo, $GUI_HIDE)
        EndSwitch
    EndIf
;#ce

    ; If a temporary combo exists
    If $hTmp_Combo <> 0 Then
        ; If ENTER pressed
        If _IsPressed("0D", $dll) Then
            ; Set label to edit content
            $sText = GUICtrlRead($hTmp_Combo)
            _GUICtrlListView_SetItemText($hListView, $aLV_Click_Info[0], $sText, $aLV_Click_Info[1])
            ; Delete temporary combo
            GUICtrlDelete($hTmp_combo)
            $hTmp_Combo = 0
            GUICtrlSetState($hListView, $GUI_ENABLE)
        EndIf
        ; If ESC pressed
        If _IsPressed("1B", $dll) Then
            ; Delete temporary combo
            GUICtrlDelete($hTmp_Combo)
            $hTmp_Combo = 0
            GUICtrlSetState($hListView, $GUI_ENABLE)
        EndIf
    EndIf

    ; If an item was double clicked
    If $fDblClk Then
        $fDblClk = False
        ; Delete an existing temporary combo
        GUICtrlDelete($hTmp_Combo)
        ; Get label position
        Switch $aLV_Click_Info[1]
            Case 0 ; On Item
                $aLV_Rect_Info = _GUICtrlListView_GetItemRect($hListView, $aLV_Click_Info[0], 2)
            Case Else ; On SubItem
                $aLV_Rect_Info = _GUICtrlListView_GetSubItemRect($hListView, $aLV_Click_Info[0], $aLV_Click_Info[1])
        EndSwitch
        ; Create temporary combo
        $hTmp_Combo = GUICtrlCreateCombo("", $aLV_Rect_Info[0] + 20, $aLV_Rect_Info[1] + 40, 100, $aLV_Rect_Info[3] - $aLV_Rect_Info[1])
        GUICtrlSetData($hTmp_Combo, "Tom|Dick|Harry")
        GUICtrlSetState($hListView, $GUI_DISABLE)
        GUICtrlSetState($hTmp_Combo, BitOR($GUI_FOCUS, $GUI_ONTOP))

    EndIf

WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)

    ; If a combo exists, return immediately
    If $hTmp_Combo <> 0 Then Return $GUI_RUNDEFMSG

    Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    If HWnd(DllStructGetData($tNMHDR, "hWndFrom")) = $hListView And DllStructGetData($tNMHDR, "Code") = $NM_DBLCLK Then
        $aLV_Click_Info = _GUICtrlListView_SubItemHitTest($hListView)
        ; As long as the click was on an item or subitem
        If $aLV_Click_Info[0] <> -1 Then $fDblClk = True
    EndIf
    Return $GUI_RUNDEFMSG

EndFunc

Please ask if you have any questions - after you have read the tutorial! :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

misterDee,

Of course it is! But you need to do a lot of the work that AutoIt ususally does for you - go and read the Tabs tutorial in the Wiki to find out why. :)

And here is the proof: :P

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#Include <GuiTab.au3>

#include <Misc.au3>

; We use ESC to exit the temporary Combo
Opt("GUICloseOnESC", 0)

; Set flag to indicate double click in ListView
Global $fDblClk = False
; Declare global variables
Global $aLV_Click_Info, $hTmp_Combo = 0

; Open DLL for _IsPressed
$dll = DllOpen("user32.dll")

$hGUI = GUICreate("Test", 500, 500)

$hTab = GUICtrlCreateTab(10, 10, 480, 480)

$hTab0 = GUICtrlCreateTabItem("Tab 0")

$hListView = _GUICtrlListView_Create($hGUI, "Col 0|Col 1|Col 2", 20, 40, 242, 200)
_GUICtrlListView_AddItem($hListView, "Item 00",0)
_GUICtrlListView_AddSubItem($hListView, 0, "Item 01", 1)
_GUICtrlListView_AddSubItem($hListView, 0, "Item 02", 2)
_GUICtrlListView_AddItem($hListView, "Item 10",1)
_GUICtrlListView_AddItem($hListView, "Item 20",2)
_GUICtrlListView_AddItem($hListView, "Item 30",3)

$hTab1 = GUICtrlCreateTabItem("Tab 1")

GUICtrlCreateTabItem("")    ; end tabitem definition

GUISetState()

; Look for double clicks
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

$iLastTab = 0

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            DllClose($dll)
            Exit
    EndSwitch
;#cs
    ; Check which Tab is active
    $iCurrTab = _GUICtrlTab_GetCurFocus($hTab)
    ; If the Tab has changed
    If $iCurrTab <> $iLastTab Then
        ; Store the value for future comparisons
        $iLastTab = $iCurrTab
        ; Show/Hide controls as required
        Switch $iCurrTab
            Case 0
                ControlShow($hGUI, "", $hListView)
                GUICtrlSetState($hTmp_Combo, $GUI_SHOW)
            Case 1
                ControlHide($hGUI, "", $hListView)
                GUICtrlSetState($hTmp_Combo, $GUI_HIDE)
        EndSwitch
    EndIf
;#ce

    ; If a temporary combo exists
    If $hTmp_Combo <> 0 Then
        ; If ENTER pressed
        If _IsPressed("0D", $dll) Then
            ; Set label to edit content
            $sText = GUICtrlRead($hTmp_Combo)
            _GUICtrlListView_SetItemText($hListView, $aLV_Click_Info[0], $sText, $aLV_Click_Info[1])
            ; Delete temporary combo
            GUICtrlDelete($hTmp_combo)
            $hTmp_Combo = 0
            GUICtrlSetState($hListView, $GUI_ENABLE)
        EndIf
        ; If ESC pressed
        If _IsPressed("1B", $dll) Then
            ; Delete temporary combo
            GUICtrlDelete($hTmp_Combo)
            $hTmp_Combo = 0
            GUICtrlSetState($hListView, $GUI_ENABLE)
        EndIf
    EndIf

    ; If an item was double clicked
    If $fDblClk Then
        $fDblClk = False
        ; Delete an existing temporary combo
        GUICtrlDelete($hTmp_Combo)
        ; Get label position
        Switch $aLV_Click_Info[1]
            Case 0 ; On Item
                $aLV_Rect_Info = _GUICtrlListView_GetItemRect($hListView, $aLV_Click_Info[0], 2)
            Case Else ; On SubItem
                $aLV_Rect_Info = _GUICtrlListView_GetSubItemRect($hListView, $aLV_Click_Info[0], $aLV_Click_Info[1])
        EndSwitch
        ; Create temporary combo
        $hTmp_Combo = GUICtrlCreateCombo("", $aLV_Rect_Info[0] + 20, $aLV_Rect_Info[1] + 40, 100, $aLV_Rect_Info[3] - $aLV_Rect_Info[1])
        GUICtrlSetData($hTmp_Combo, "Tom|Dick|Harry")
        GUICtrlSetState($hListView, $GUI_DISABLE)
        GUICtrlSetState($hTmp_Combo, BitOR($GUI_FOCUS, $GUI_ONTOP))

    EndIf

WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)

    ; If a combo exists, return immediately
    If $hTmp_Combo <> 0 Then Return $GUI_RUNDEFMSG

    Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    If HWnd(DllStructGetData($tNMHDR, "hWndFrom")) = $hListView And DllStructGetData($tNMHDR, "Code") = $NM_DBLCLK Then
        $aLV_Click_Info = _GUICtrlListView_SubItemHitTest($hListView)
        ; As long as the click was on an item or subitem
        If $aLV_Click_Info[0] <> -1 Then $fDblClk = True
    EndIf
    Return $GUI_RUNDEFMSG

EndFunc

Please ask if you have any questions - after you have read the tutorial! :)

M23

Wauw, wise man (Y), thnx, big time!!
Link to comment
Share on other sites

misterDee,

Of course it is! But you need to do a lot of the work that AutoIt ususally does for you - go and read the Tabs tutorial in the Wiki to find out why. :P

And here is the proof: :D

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#Include <GuiTab.au3>

#include <Misc.au3>

; We use ESC to exit the temporary Combo
Opt("GUICloseOnESC", 0)

; Set flag to indicate double click in ListView
Global $fDblClk = False
; Declare global variables
Global $aLV_Click_Info, $hTmp_Combo = 0

; Open DLL for _IsPressed
$dll = DllOpen("user32.dll")

$hGUI = GUICreate("Test", 500, 500)

$hTab = GUICtrlCreateTab(10, 10, 480, 480)

$hTab0 = GUICtrlCreateTabItem("Tab 0")

$hListView = _GUICtrlListView_Create($hGUI, "Col 0|Col 1|Col 2", 20, 40, 242, 200)
_GUICtrlListView_AddItem($hListView, "Item 00",0)
_GUICtrlListView_AddSubItem($hListView, 0, "Item 01", 1)
_GUICtrlListView_AddSubItem($hListView, 0, "Item 02", 2)
_GUICtrlListView_AddItem($hListView, "Item 10",1)
_GUICtrlListView_AddItem($hListView, "Item 20",2)
_GUICtrlListView_AddItem($hListView, "Item 30",3)

$hTab1 = GUICtrlCreateTabItem("Tab 1")

GUICtrlCreateTabItem("")    ; end tabitem definition

GUISetState()

; Look for double clicks
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

$iLastTab = 0

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            DllClose($dll)
            Exit
    EndSwitch
;#cs
    ; Check which Tab is active
    $iCurrTab = _GUICtrlTab_GetCurFocus($hTab)
    ; If the Tab has changed
    If $iCurrTab <> $iLastTab Then
        ; Store the value for future comparisons
        $iLastTab = $iCurrTab
        ; Show/Hide controls as required
        Switch $iCurrTab
            Case 0
                ControlShow($hGUI, "", $hListView)
                GUICtrlSetState($hTmp_Combo, $GUI_SHOW)
            Case 1
                ControlHide($hGUI, "", $hListView)
                GUICtrlSetState($hTmp_Combo, $GUI_HIDE)
        EndSwitch
    EndIf
;#ce

    ; If a temporary combo exists
    If $hTmp_Combo <> 0 Then
        ; If ENTER pressed
        If _IsPressed("0D", $dll) Then
            ; Set label to edit content
            $sText = GUICtrlRead($hTmp_Combo)
            _GUICtrlListView_SetItemText($hListView, $aLV_Click_Info[0], $sText, $aLV_Click_Info[1])
            ; Delete temporary combo
            GUICtrlDelete($hTmp_combo)
            $hTmp_Combo = 0
            GUICtrlSetState($hListView, $GUI_ENABLE)
        EndIf
        ; If ESC pressed
        If _IsPressed("1B", $dll) Then
            ; Delete temporary combo
            GUICtrlDelete($hTmp_Combo)
            $hTmp_Combo = 0
            GUICtrlSetState($hListView, $GUI_ENABLE)
        EndIf
    EndIf

    ; If an item was double clicked
    If $fDblClk Then
        $fDblClk = False
        ; Delete an existing temporary combo
        GUICtrlDelete($hTmp_Combo)
        ; Get label position
        Switch $aLV_Click_Info[1]
            Case 0 ; On Item
                $aLV_Rect_Info = _GUICtrlListView_GetItemRect($hListView, $aLV_Click_Info[0], 2)
            Case Else ; On SubItem
                $aLV_Rect_Info = _GUICtrlListView_GetSubItemRect($hListView, $aLV_Click_Info[0], $aLV_Click_Info[1])
        EndSwitch
        ; Create temporary combo
        $hTmp_Combo = GUICtrlCreateCombo("", $aLV_Rect_Info[0] + 20, $aLV_Rect_Info[1] + 40, 100, $aLV_Rect_Info[3] - $aLV_Rect_Info[1])
        GUICtrlSetData($hTmp_Combo, "Tom|Dick|Harry")
        GUICtrlSetState($hListView, $GUI_DISABLE)
        GUICtrlSetState($hTmp_Combo, BitOR($GUI_FOCUS, $GUI_ONTOP))

    EndIf

WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)

    ; If a combo exists, return immediately
    If $hTmp_Combo <> 0 Then Return $GUI_RUNDEFMSG

    Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    If HWnd(DllStructGetData($tNMHDR, "hWndFrom")) = $hListView And DllStructGetData($tNMHDR, "Code") = $NM_DBLCLK Then
        $aLV_Click_Info = _GUICtrlListView_SubItemHitTest($hListView)
        ; As long as the click was on an item or subitem
        If $aLV_Click_Info[0] <> -1 Then $fDblClk = True
    EndIf
    Return $GUI_RUNDEFMSG

EndFunc

Please ask if you have any questions - after you have read the tutorial! :)

M23

Very difficult M23, even the tabs... i write a new tab, but it will always shows on the first tabitem, is it also possible to edit 1 column? for the combo's? :)
Link to comment
Share on other sites

  • Moderators

misterDee,

First, when you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. :P

i write a new tab, but it will always shows on the first tabitem

What always shows? :) The script I posted shows how you need to Hide/Show items if they are not native controls.

is it also possible to edit 1 column? for the combo's?

Again, I have little idea of what you want here. Do you mean you want to be able to decide the content of the combo? :)

Please explain in a little more detail - and perhaps post the code you are having trouble with - and I will do my best to help. But just a couple of phrases is not really enought to work on. :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

What always shows? :P The script I posted shows how you need to Hide/Show items if they are not native controls.

Ok, but if i will make three tabitems, the part of my code will always shows in the first tab, no mather if i place it under the second of third tabitem

Again, I have little idea of what you want here. Do you mean you want to be able to decide the content of the combo? :)

No, i want 1 colum that you can edit with combo, lets say in your script only the items in 'Col 2'

Please explain in a little more detail - and perhaps post the code you are having trouble with - and I will do my best to help. But just a couple of phrases is not really enought to work on. :D

sorry man, its very difficult for me to bring over what i want ;), below this page is my script, you can see the tabs/listview (wrong version), what i want is in all the colums simple text and in under the colum 'Status' must be a combobox, so i can edit the 'Status' of a item and insert that in a database.

im really appreciate your hulp! :), I hope that I am clear enough :)

#include <date.au3>
#include <string.au3>
#include <INet.au3>
#include <File.au3>
#include <Process.au3>
#include <GuiComboBox.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListviewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTreeView.au3>
#include <GuiListView.au3>
#Include <GuiTab.au3>

;Globalizeren
global $db_artikelcode
global $db_omschrijving
global $db_bestelnummer
global $db_inkoopprijs
global $db_aantal
global $db_opmerking
global $db_klant
global $db_aanmelder
global $db_status

;DB connect
$FULL_MDB_FILE_NAME = @ScriptDir & "\database\db.mdb"
$dbpass="th3m3n4c3"
$CONN = ObjCreate("ADODB.Connection")
$CONN.Open('Driver={Microsoft Access Driver (*.mdb)};Dbq=' & $FULL_MDB_FILE_NAME & ";PWD=" & $dbpass& ';')
$RecordSet = ObjCreate("ADODB.Recordset")

;Gui
$gui=GUICreate("Technofarm BETA v0.99 - Inlogd als: Ter Aar ", 790, 700, 134, 10, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_APPWINDOW, $WS_MINIMIZEBOX, $WS_EX_RIGHT, $WS_EX_WINDOWEDGE))
GUICtrlCreatePic(@ScriptDir & "\images\main_bg_top.jpg", 0, 0, 790, 78)
GUICtrlCreatePic(@ScriptDir & "\images\main_bg_bottom.jpg", 0, 666, 790, 35)
GUISetBkColor(0xFFFFFF)
$tab=GUICtrlCreateTab(0, 76, 800, 700) 
GUICtrlCreateTabItem("Dashboard")
GUICtrlCreateTabItem("Bestellingenlijst Bodegraven")
GUICtrlCreateTabItem("Bestellingenlijst Ter Aar")

$listview_ta=GUICtrlCreateListView("Artikelcode | Artikelomschrijving | Bestelnummer | Inkoopprijs | Aantal | Opmerking | Klant | Aanmelder | Status", 0, 110, 791, 524, "", $LVS_EX_GRIDLINES); + $LVS_EX_CHECKBOXES)

$bestellingen=$conn.Execute("SELECT * FROM bestellingen_teraar") 
    With $bestellingen
    While NOT .EOF
        $db_artikelcode=.fields("artikelcode").value
        $db_omschrijving=.fields("artikelomschrijving").value
        $db_bestelnummer=.fields("bestelnummer").value
        $db_inkoopprijs=.fields("inkoopprijs").value
        $db_aantal=.fields("aantal").value
        $db_opmerking=.fields("opmerking").value
        $db_klant=.fields("klant").value
        $db_aanmelder=.fields("aanmelder").value
        $db_status=.fields("status").value
            Guictrlcreatelistviewitem($db_artikelcode &"|"& $db_omschrijving &"|"& $db_bestelnummer &"|"& $db_inkoopprijs &"|"& $db_aantal &"|"& $db_opmerking &"|"& $db_klant &"|"& $db_aanmelder &"|"& $db_status, $listview_ta)
    .Movenext
WEnd
EndWith 

GUICtrlCreateTabItem("Bestellingenlijst Leimuiden")
GUICtrlCreateTabItem("Gebruikersoverzicht")


GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Thnx D!

Link to comment
Share on other sites

  • Moderators

misterDee,

You have to do better than that. :)

You need a ListView created with the GUIListView UDF to get the combo to appear and I have shown you in my script exactly how to get such a ListView to appear/hide when you use tabs. You need to at least make an attempt to integrate that into your script - I am not writing it all for you. :P

As to limiting the combo to a certain column, you need to check for the column in the message handler like this:

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)

    ; If a combo exists, return immediately
    If $hTmp_Combo <> 0 Then Return $GUI_RUNDEFMSG

    Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    If HWnd(DllStructGetData($tNMHDR, "hWndFrom")) = $hListView And DllStructGetData($tNMHDR, "Code") = $NM_DBLCLK Then
        $aLV_Click_Info = _GUICtrlListView_SubItemHitTest($hListView)
        ; As long as the click was on the ListView
        If $aLV_Click_Info[0] <> -1 Then
            ; Check it was in Col 2
            If $aLV_Click_Info[1] = 2 Then $fDblClk = True
        EndIf
    EndIf
    Return $GUI_RUNDEFMSG

EndFunc

If you put that in the script I posted earlier, you only get the combo when you click on Col 2. :)

Now go and try to code a ListView created with the UDF in your script (look at the example for _GUICtrlListView_Create to see what commands you need) and adjust the While...WEnd loop in your script so that it is hidden/shown depending on the tab selected (you have the basic idea in the script I posted above).

If you run into difficulties, you know where I am - but you have to do some work first. :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

If you run into difficulties, you know where I am - but you have to do some work first. :)

M23

Melba,

Thnx again for your support and script, works great! i have whole day dubbin' about to get the listview under a 2nd/3th tabitem but its still shows up on the first tab.

What am i doing wrong? if im putting text\buttons etc.. under a tabitem its working great but the giving listview not.. hmm.. strange! :) ive reading and checking all examples, can you give me a hint?

Thnx!

Link to comment
Share on other sites

  • Moderators

misterDee,

Post what you have so far. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

misterDee,

Post what you have so far. :)

M23

Here it is, its mixed, the script you gave me stands under the tabitem 'Ter Aar' but it always starts under 'dashboard', can you tell me what im doing wrong?

Sorry for my English at some times

#include <date.au3>
#include <string.au3>
#include <misc.au3>
#include <File.au3>
#include <Process.au3>
#include <GuiComboBox.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListviewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTreeView.au3>
#include <GuiListView.au3>
#Include <GuiTab.au3>

;Globalizeren
global $db_artikelcode
global $db_omschrijving
global $db_bestelnummer
global $db_inkoopprijs
global $db_aantal
global $db_opmerking
global $db_klant
global $db_aanmelder
global $db_status

;DB connect
$FULL_MDB_FILE_NAME = @ScriptDir & "\database\db.mdb"
$dbpass="th3m3n4c3"
$CONN = ObjCreate("ADODB.Connection")
$CONN.Open('Driver={Microsoft Access Driver (*.mdb)};Dbq=' & $FULL_MDB_FILE_NAME & ";PWD=" & $dbpass& ';')
$RecordSet = ObjCreate("ADODB.Recordset")

; We use ESC to exit the temporary Combo
Opt("GUICloseOnESC", 0)
; Set flag to indicate double click in ListView
Global $fDblClk = False
; Declare global variables
Global $aLV_Click_Info, $hTmp_Combo = 0
; Open DLL for _IsPressed
$dll = DllOpen("user32.dll")

;Gui
$hgui=GUICreate("Technofarm BETA v0.99 - Inlogd als: Ter Aar ", 790, 700, 134, 10, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_APPWINDOW, $WS_MINIMIZEBOX, $WS_EX_RIGHT, $WS_EX_WINDOWEDGE))
GUICtrlCreatePic(@ScriptDir & "\images\main_bg_top.jpg", 0, 0, 790, 78)
GUICtrlCreatePic(@ScriptDir & "\images\main_bg_bottom.jpg", 0, 666, 790, 35)
GUISetBkColor(0xFFFFFF)
$htab=GUICtrlCreateTab(0, 76, 800, 700) 
GUICtrlCreateTabItem("Dashboard")
GUICtrlCreateTabItem("Bestellingenlijst Bodegraven")
GUICtrlCreateTabItem("Bestellingenlijst Ter Aar")

$hListView = _GUICtrlListView_Create($hgui, "Col 0|Col 1|Col 2", 0, 110, 791, 524)
             _GUICtrlListView_AddItem($hlistview, "Item 00",0)
             _GUICtrlListView_AddSubItem($hListView, 0, "Item 01", 1)
             _GUICtrlListView_AddSubItem($hListView, 0, "Item 02", 2)
             _GUICtrlListView_AddItem($hListView, "Item 10",1)
             _GUICtrlListView_AddItem($hListView, "Item 20",2)
             _GUICtrlListView_AddItem($hListView, "Item 30",3)

GUICtrlCreateTabItem("Bestellingenlijst Leimuiden")
GUICtrlCreateTabItem("Gebruikersoverzicht")


; Look for double clicks
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

$iLastTab = 0
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        DllClose($dll)
            Exit
    EndSwitch

    ; Check which Tab is active
    $iCurrTab = _GUICtrlTab_GetCurFocus($htab)
    ; If the Tab has changed
    If $iCurrTab <> $iLastTab Then
        ; Store the value for future comparisons
        $iLastTab = $iCurrTab
        ; Show/Hide controls as required
        Switch $iCurrTab
            Case 0
                ControlShow($hGUI, "", $hListView)
                GUICtrlSetState($hTmp_Combo, $GUI_HIDE)
            Case 1
                ControlHide($hGUI, "", $hListView)
               GUICtrlSetState($hTmp_Combo, $GUI_Hide)  
            Case 2
                ControlHide($hGUI, "", $hListView)
                 GUICtrlSetState($hTmp_Combo, $GUI_Hide)    
            Case 3
                ControlHide($hGUI, "", $hListView)
                GUICtrlSetState($hTmp_Combo, $GUI_Hide) 
        EndSwitch
    EndIf
;#ce

    ; If a temporary combo exists
    If $hTmp_Combo <> 0 Then
        ; If ENTER pressed
        If _IsPressed("0D", $dll) Then
            ; Set label to edit content
            $sText = GUICtrlRead($hTmp_Combo)
            _GUICtrlListView_SetItemText($hListView, $aLV_Click_Info[0], $sText, $aLV_Click_Info[1])
            ; Delete temporary combo
            GUICtrlDelete($hTmp_combo)
            $hTmp_Combo = 0
            GUICtrlSetState($hListView, $GUI_ENABLE)
        EndIf
        ; If ESC pressed
        If _IsPressed("1B", $dll) Then
            ; Delete temporary combo
            GUICtrlDelete($hTmp_Combo)
            $hTmp_Combo = 0
            GUICtrlSetState($hListView, $GUI_ENABLE)
        EndIf
    EndIf

    ; If an item was double clicked
    If $fDblClk Then
        $fDblClk = False
        ; Delete an existing temporary combo
        GUICtrlDelete($hTmp_Combo)
        ; Get label position
        Switch $aLV_Click_Info[1]
            Case 0 ; On Item
                $aLV_Rect_Info = _GUICtrlListView_GetItemRect($hListView, $aLV_Click_Info[0], 2)
            Case Else ; On SubItem
                $aLV_Rect_Info = _GUICtrlListView_GetSubItemRect($hListView, $aLV_Click_Info[0], $aLV_Click_Info[1])
        EndSwitch
        ; Create temporary combo
        $hTmp_Combo = GUICtrlCreateCombo("", $aLV_Rect_Info[0] + 0, $aLV_Rect_Info[1] + 110, 100, $aLV_Rect_Info[3] - $aLV_Rect_Info[1])
        GUICtrlSetData($hTmp_Combo, "Tom|Dick|Harry")
        GUICtrlSetState($hListView, $GUI_DISABLE)
        GUICtrlSetState($hTmp_Combo, BitOR($GUI_FOCUS, $GUI_ONTOP))

    EndIf

WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)

    ; If a combo exists, return immediately
    If $hTmp_Combo <> 0 Then Return $GUI_RUNDEFMSG

    Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    If HWnd(DllStructGetData($tNMHDR, "hWndFrom")) = $hListView And DllStructGetData($tNMHDR, "Code") = $NM_DBLCLK Then
        $aLV_Click_Info = _GUICtrlListView_SubItemHitTest($hListView)
        ; As long as the click was on the ListView
        If $aLV_Click_Info[0] <> -1 Then
            ; Check it was in Col 2
            If $aLV_Click_Info[1] = 2 Then $fDblClk = True
        EndIf
    EndIf
    Return $GUI_RUNDEFMSG

EndFunc

Thnx!, for teaching me! :)

Link to comment
Share on other sites

  • Moderators

misterDee,

Pretty close - look for the <<<<<<<<<< lines: :)

#include <date.au3>
#include <string.au3>
#include <misc.au3>
#include <File.au3>
#include <Process.au3>
#include <GuiComboBox.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListviewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTreeView.au3>
#include <GuiListView.au3>
#Include <GuiTab.au3>

;Globalizeren
global $db_artikelcode
global $db_omschrijving
global $db_bestelnummer
global $db_inkoopprijs
global $db_aantal
global $db_opmerking
global $db_klant
global $db_aanmelder
global $db_status

;DB connect
$FULL_MDB_FILE_NAME = @ScriptDir & "\database\db.mdb"
$dbpass="th3m3n4c3"
;$CONN = ObjCreate("ADODB.Connection")
;$CONN.Open('Driver={Microsoft Access Driver (*.mdb)};Dbq=' & $FULL_MDB_FILE_NAME & ";PWD=" & $dbpass& ';')
;$RecordSet = ObjCreate("ADODB.Recordset")

; We use ESC to exit the temporary Combo
Opt("GUICloseOnESC", 0)
; Set flag to indicate double click in ListView
Global $fDblClk = False
; Declare global variables
Global $aLV_Click_Info, $hTmp_Combo = 0
; Open DLL for _IsPressed
$dll = DllOpen("user32.dll")

;Gui
$hgui=GUICreate("Technofarm BETA v0.99 - Inlogd als: Ter Aar ", 790, 700, 134, 10, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_APPWINDOW, $WS_MINIMIZEBOX, $WS_EX_RIGHT, $WS_EX_WINDOWEDGE))
GUICtrlCreatePic(@ScriptDir & "\images\main_bg_top.jpg", 0, 0, 790, 78)
GUICtrlCreatePic(@ScriptDir & "\images\main_bg_bottom.jpg", 0, 666, 790, 35)
GUISetBkColor(0xFFFFFF)
$htab=GUICtrlCreateTab(0, 76, 800, 700)
GUICtrlCreateTabItem("Dashboard")                               ; This is Tab 0 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
GUICtrlCreateTabItem("Bestellingenlijst Bodegraven")            ; This is Tab 1 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
GUICtrlCreateTabItem("Bestellingenlijst Ter Aar")               ; This is Tab 2 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

$hListView = _GUICtrlListView_Create($hgui, "Col 0|Col 1|Col 2", 0, 110, 791, 524)
             _GUICtrlListView_AddItem($hlistview, "Item 00",0)
             _GUICtrlListView_AddSubItem($hListView, 0, "Item 01", 1)
             _GUICtrlListView_AddSubItem($hListView, 0, "Item 02", 2)
             _GUICtrlListView_AddItem($hListView, "Item 10",1)
             _GUICtrlListView_AddItem($hListView, "Item 20",2)
             _GUICtrlListView_AddItem($hListView, "Item 30",3)

ControlHide($hGUI, "", $hListView) ; Hide the ListView initially <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

GUICtrlCreateTabItem("Bestellingenlijst Leimuiden")              ; This is Tab 3 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
GUICtrlCreateTabItem("Gebruikersoverzicht")                      ; This is Tab 4 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

GUICtrlCreateTabItem("")

; Look for double clicks
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

$iLastTab = 0

GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        DllClose($dll)
            Exit
    EndSwitch

    ; Check which Tab is active
    $iCurrTab = _GUICtrlTab_GetCurFocus($htab)
    ; If the Tab has changed
    If $iCurrTab <> $iLastTab Then
        ; Store the value for future comparisons
        $iLastTab = $iCurrTab
        ; Show/Hide controls as required
        Switch $iCurrTab
            Case 0
                ControlHide($hGUI, "", $hListView)
                GUICtrlSetState($hTmp_Combo, $GUI_HIDE)
            Case 1
                ControlHide($hGUI, "", $hListView)
               GUICtrlSetState($hTmp_Combo, $GUI_Hide)
            Case 2
                ControlShow($hGUI, "", $hListView) ; So show on the correct tab <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                 GUICtrlSetState($hTmp_Combo, $GUI_SHOW)
            Case 3
                ControlHide($hGUI, "", $hListView)
                GUICtrlSetState($hTmp_Combo, $GUI_Hide)
            Case 4 ; And do not forget tab 4 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                ControlHide($hGUI, "", $hListView)
                GUICtrlSetState($hTmp_Combo, $GUI_Hide)
        EndSwitch
    EndIf
;#ce

    ; If a temporary combo exists
    If $hTmp_Combo <> 0 Then
        ; If ENTER pressed
        If _IsPressed("0D", $dll) Then
            ; Set label to edit content
            $sText = GUICtrlRead($hTmp_Combo)
            _GUICtrlListView_SetItemText($hListView, $aLV_Click_Info[0], $sText, $aLV_Click_Info[1])
            ; Delete temporary combo
            GUICtrlDelete($hTmp_combo)
            $hTmp_Combo = 0
            GUICtrlSetState($hListView, $GUI_ENABLE)
        EndIf
        ; If ESC pressed
        If _IsPressed("1B", $dll) Then
            ; Delete temporary combo
            GUICtrlDelete($hTmp_Combo)
            $hTmp_Combo = 0
            GUICtrlSetState($hListView, $GUI_ENABLE)
        EndIf
    EndIf

    ; If an item was double clicked
    If $fDblClk Then
        $fDblClk = False
        ; Delete an existing temporary combo
        GUICtrlDelete($hTmp_Combo)
        ; Get label position
        Switch $aLV_Click_Info[1]
            Case 0 ; On Item
                $aLV_Rect_Info = _GUICtrlListView_GetItemRect($hListView, $aLV_Click_Info[0], 2)
            Case Else ; On SubItem
                $aLV_Rect_Info = _GUICtrlListView_GetSubItemRect($hListView, $aLV_Click_Info[0], $aLV_Click_Info[1])
        EndSwitch
        ; Create temporary combo
        $hTmp_Combo = GUICtrlCreateCombo("", $aLV_Rect_Info[0] + 0, $aLV_Rect_Info[1] + 110, 100, $aLV_Rect_Info[3] - $aLV_Rect_Info[1])
        GUICtrlSetData($hTmp_Combo, "Tom|Dick|Harry")
        GUICtrlSetState($hListView, $GUI_DISABLE)
        GUICtrlSetState($hTmp_Combo, BitOR($GUI_FOCUS, $GUI_ONTOP))

    EndIf

WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)

    ; If a combo exists, return immediately
    If $hTmp_Combo <> 0 Then Return $GUI_RUNDEFMSG

    Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    If HWnd(DllStructGetData($tNMHDR, "hWndFrom")) = $hListView And DllStructGetData($tNMHDR, "Code") = $NM_DBLCLK Then
        $aLV_Click_Info = _GUICtrlListView_SubItemHitTest($hListView)
        ; As long as the click was on the ListView
        If $aLV_Click_Info[0] <> -1 Then
            ; Check it was in Col 2
            If $aLV_Click_Info[1] = 2 Then $fDblClk = True
        EndIf
    EndIf
    Return $GUI_RUNDEFMSG

EndFunc

All clear? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Oh, that simple, i get the trick, thnx Melba!! :) , i will show it to you if its done (If I manage to finish everything)

Melba,

Its still not clear i thought ive got it but no... again the tabitems are not working good, if i put in each tab a listview then they overlappin or i see the same listview in different tabs, whats the logic in the between the case (0,1,2,3)-settings with ControlShow/ControlHide? :)

Thnx again!!

Link to comment
Share on other sites

  • Moderators

misterDee,

I have shown you twice and pointed you at the Wiki tutorial..... :)

For the last time (and this is all in the tutorial :P):

AutoIt looks after native controls if you create them within the tab structure.

For UDF-created controls, you must use ControlHide on the tabs where you do not want to see them and ControlShow on the tab where you do want to see them.

If you cannot get it to work ... post the code. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I have shown you twice and pointed you at the Wiki tutorial..... :)

For the last time (and this is all in the tutorial ;)):

Tutorials :), read it and fixed it.. easy as it was :D

But the combo-script is set on 1 listview, but now ive got 2.. ive try to edit the var into 2 but i doesnt work can i make multi vars on $hlistview? :P

Link to comment
Share on other sites

  • Moderators

misterDee,

This hows you how to deal with multiple ListViews. Basically, put the ListView handles into an array so you can tell which has been clicked. :)

If you get stuck, just post your code and I will take a look. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

If you get stuck, just post your code and I will take a look. :)

Im stuck! :P, its problly a very simple edit? :)

#include <date.au3>
#include <string.au3>
#include <misc.au3>
#include <File.au3>
#include <Process.au3>
#include <GuiComboBox.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListviewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTreeView.au3>
#include <GuiListView.au3>
#Include <GuiTab.au3>

;Globalizeren
global $db_artikelcode
global $db_omschrijving
global $db_bestelnummer
global $db_inkoopprijs
global $db_aantal
global $db_opmerking
global $db_klant
global $db_aanmelder
global $db_status

;DB connect
$FULL_MDB_FILE_NAME = @ScriptDir & "\database\db.mdb"
;$dbpass=""
;$CONN = ObjCreate("ADODB.Connection")
;$CONN.Open('Driver={Microsoft Access Driver (*.mdb)};Dbq=' & $FULL_MDB_FILE_NAME & ";PWD=" & $dbpass& ';')
;$RecordSet = ObjCreate("ADODB.Recordset")

; We use ESC to exit the temporary Combo
Opt("GUICloseOnESC", 0)
; Set flag to indicate double click in ListView
Global $fDblClk = False
; Declare global variables
Global $aLV_Click_Info, $hTmp_Combo = 0
; Open DLL for _IsPressed
$dll = DllOpen("user32.dll")

;Gui
$GUI=GUICreate("Technofarm BETA v0.99 - Inlogd als: Ter Aar ", 790, 700, 134, 10, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_APPWINDOW, $WS_MINIMIZEBOX, $WS_EX_RIGHT, $WS_EX_WINDOWEDGE))
GUICtrlCreatePic(@ScriptDir & "\images\main_bg_top.jpg", 0, 0, 790, 78)
GUICtrlCreatePic(@ScriptDir & "\images\main_bg_bottom.jpg", 0, 666, 790, 35)
GUISetBkColor(0xFFFFFF)
$TAB=GUICtrlCreateTab(0, 76, 800, 700)
GUICtrlCreateTabItem("Dashboard")                              
GUICtrlCreateTabItem("Bestellingenlijst Bodegraven")            
$listview_bg=_GUICtrlListView_Create($GUI, "Col 0|Col 1|Col 2", 0, 110, 791, 524)
             _GUICtrlListView_AddItem($listview_bg, "Item 00",0)
             _GUICtrlListView_AddSubItem($listview_bg, 0, "Item 01", 1)
             _GUICtrlListView_AddSubItem($listview_bg, 0, "Item 02", 2)
             _GUICtrlListView_AddItem($listview_bg, "Item 10",1)
             _GUICtrlListView_AddItem($listview_bg, "Item 20",2)
             _GUICtrlListView_AddItem($listview_bg, "Item 30",3)
ControlHide($GUI, "", $listview_bg)          

GUICtrlCreateTabItem("Bestellingenlijst Ter Aar")               
$listview_ta=_GUICtrlListView_Create($GUI, "Col 3|Col 4|Col 5", 0, 110, 791, 524)
             _GUICtrlListView_AddItem($listview_ta, "Item 00",0)
             _GUICtrlListView_AddSubItem($listview_ta, 0, "Item 01", 1)
             _GUICtrlListView_AddSubItem($listview_ta, 0, "Item 02", 2)
             _GUICtrlListView_AddItem($listview_ta, "Item 10",1)
             _GUICtrlListView_AddItem($listview_ta, "Item 20",2)
             _GUICtrlListView_AddItem($listview_ta, "Item 30",3)
ControlHide($GUI, "", $listview_ta) 

GUICtrlCreateTabItem("Bestellingenlijst Leimuiden")             
GUICtrlCreateTabItem("Gebruikersoverzicht")                      

GUICtrlCreateTabItem("")

; Look for double clicks
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

$iLastTab = 0
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        DllClose($dll)
            Exit
    EndSwitch

    ; Check which Tab is active
    $iCurrTab = _GUICtrlTab_GetCurFocus($TAB)
    ; If the Tab has changed
    If $iCurrTab <> $iLastTab Then
        ; Store the value for future comparisons
        $iLastTab = $iCurrTab
        ; Show/Hide controls as required
        Switch $iCurrTab
            Case 0
                ControlHide($GUI, "", $listview_bg)
                ControlHide($GUI, "", $listview_ta)
            Case 1
                ControlHide($GUI, "", $listview_ta)
                ControlShow($GUI, "", $listview_bg)
             Case 2
                ControlHide($GUI, "", $listview_bg)
                ControlShow($GUI, "", $listview_ta)
           ; Case 3
            ;    ControlHide($hGUI, "", $hListView)
             ;   GUICtrlSetState($hTmp_Combo, $GUI_Hide)
            ;Case 4 ; And do not forget tab 4 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
             ;   ControlHide($hGUI, "", $hListView)
              ;  GUICtrlSetState($hTmp_Combo, $GUI_Hide)
        EndSwitch
    EndIf
;#ce

    ; If a temporary combo exists
    If $hTmp_Combo <> 0 Then
        ; If ENTER pressed
        If _IsPressed("0D", $dll) Then
            ; Set label to edit content
            $sText = GUICtrlRead($hTmp_Combo)
            _GUICtrlListView_SetItemText($hListView, $aLV_Click_Info[0], $sText, $aLV_Click_Info[1])
            ; Delete temporary combo
            GUICtrlDelete($hTmp_combo)
            $hTmp_Combo = 0
            GUICtrlSetState($hListView, $GUI_ENABLE)
        EndIf
        ; If ESC pressed
        If _IsPressed("1B", $dll) Then
            ; Delete temporary combo
            GUICtrlDelete($hTmp_Combo)
            $hTmp_Combo = 0
            GUICtrlSetState($hListView, $GUI_ENABLE)
        EndIf
    EndIf

    ; If an item was double clicked
    If $fDblClk Then
        $fDblClk = False
        ; Delete an existing temporary combo
        GUICtrlDelete($hTmp_Combo)
        ; Get label position
        Switch $aLV_Click_Info[1]
            Case 0 ; On Item
                $aLV_Rect_Info = _GUICtrlListView_GetItemRect($hListView, $aLV_Click_Info[0], 2)
            Case Else ; On SubItem
                $aLV_Rect_Info = _GUICtrlListView_GetSubItemRect($hListView, $aLV_Click_Info[0], $aLV_Click_Info[1])
        EndSwitch
        ; Create temporary combo
        $hTmp_Combo = GUICtrlCreateCombo("", $aLV_Rect_Info[0] + 0, $aLV_Rect_Info[1] + 110, 100, $aLV_Rect_Info[3] - $aLV_Rect_Info[1])
        GUICtrlSetData($hTmp_Combo, "Tom|Dick|Harry")
        GUICtrlSetState($hListView, $GUI_DISABLE)
        GUICtrlSetState($hTmp_Combo, BitOR($GUI_FOCUS, $GUI_ONTOP))

    EndIf

WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)

    ; If a combo exists, return immediately
    If $hTmp_Combo <> 0 Then Return $GUI_RUNDEFMSG

    Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    If HWnd(DllStructGetData($tNMHDR, "hWndFrom")) = $hListView And DllStructGetData($tNMHDR, "Code") = $NM_DBLCLK Then
        $aLV_Click_Info = _GUICtrlListView_SubItemHitTest($hListView)
        ; As long as the click was on the ListView
        If $aLV_Click_Info[0] <> -1 Then
            ; Check it was in Col 2
            If $aLV_Click_Info[1] = 2 Then $fDblClk = True
        EndIf
    EndIf
    Return $GUI_RUNDEFMSG

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