Jump to content
Sign in to follow this  
Israelks

Combo dentro de Listview

Recommended Posts

Olá Israelks.

 

Puxa, agora vc está forçando a amizade...

 

Realmente não sei. Nunca tentei. Por quê vc não tenta e nos avise se funcionou?

 

Vou dar uma olhada no fórum americano se alguém já fez isso.

Share this post


Link to post
Share on other sites

Estou procurando nas bandas de lá também hahaha

#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

este foi o melhor exemplo que encontrei, estou fazendo umas mudanças e fazendo do meu jeito!

  • Like 1

Share this post


Link to post
Share on other sites

Vê se isso aqui te serve

#include <GUIConstants.au3>
#include <guilistview.au3>
#include <constants.au3>
;~ Global Const $WM_COMMAND = 0x0111
;~ Global Const  $CBN_DROPDOWN = 7
;~ Global Const $CBN_CLOSEUP = 8

#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 413, 298, 208, 142)
$LV = GUICtrlCreateListView("title", 8, 24, 160, 150)
GUICtrlSendMsg(-1, 0x101E, 0, 100)
$ListView1_0 = GUICtrlCreateListViewItem("B5:AB :8@8;;8FK", $LV)
$ListView1_1 = GUICtrlCreateListViewItem("bbbbbbbbbbbb", $LV)
$ListView1_2 = GUICtrlCreateListViewItem("B5AB", $LV)
$ListView1_3 = GUICtrlCreateListViewItem("dddddddddd", $LV)
$ListView1_4 = GUICtrlCreateListViewItem("eeeeeeeeeeeeee", $LV)
$ListView1_5 = GUICtrlCreateListViewItem("ffffffffffffff", $LV)
$ListView1_6 = GUICtrlCreateListViewItem("gggggggggggggg", $LV)
$Combo1 = GUICtrlCreateCombo("Combo1", 168, 152, 100, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL,$WS_CLIPSIBLINGS))
GUICtrlSetData(-1,"one|two|three|four")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUICtrlSetState($combo1,$GUI_ONTOP)
GUICtrlSetState($combo1,$GUI_HIDE)

GUIRegisterMsg($WM_COMMAND,"MY_WM_COMMAND")
Global $lvit
$LVItHt = 14
$LVPos = ControlGetPos("Form2","",$LV)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $GUI_EVENT_PRIMARYDOWN
            ;get info on control the mouse is over
            $Info =  GUIGetCursorInfo (WinGetHandle($Form2))
            If $Info[4] = $LV Then ;if over the Listview
                setcombo()            ;get the text of the selected item
            EndIf

    EndSwitch
WEnd


Func setcombo()

    $lvit = _GUICtrlListView_GetNextItem($lv)
    ConsoleWrite("row = " & $lvit & @CRLF)
    GUICtrlSetPos($combo1,$LVPos[0] + 4,$LVPos[1] + $lvit*$LVItHt + 20)
    GUICtrlSetState($combo1,BitOR($GUI_ONTOP,$GUI_SHOW))
    DllCall("user32.dll", "int", "InvalidateRect", "hwnd", GUICtrlGetHandle($Combo1), "int", 0, "int", 1)


EndFunc



Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    Local $nNotifyCode = _HiWord($wParam)
    Local $nID = _LoWord($wParam)
    Local $hCtrl = $lParam

    Switch $nID
        Case $combo1
            Switch $nNotifyCode

                Case $CBN_CLOSEUP
                    _GUICtrlListView_SetItemText($lv,$lvit,0,GUICtrlRead($combo1))
                    GUICtrlSetState($combo1,$GUI_HIDE)
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;MY_WM_COMMAND




Func _HiWord($x)
    Return BitShift($x, 16)
EndFunc   ;==>_HiWord

Func _LoWord($x)
    Return BitAND($x, 0xFFFF)
EndFunc   ;==>_LoWord

https://www.autoitscript.com/forum/topic/50304-listview-combobox/

  • Like 1

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  

×