Moderators Melba23 Posted March 13, 2011 Moderators Posted March 13, 2011 misterDee,Im stuck!Well, you did not try very hard to get out yourself. I gave you the basic hint (an array of handles) and even pointed you to a script which showed you exactly what to do. All you had to do was integrate it like this:expandcollapse popup#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 Global $aListView[2] ;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, $hListView = 0 ; 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) $aListView[0] = $listview_bg ; Put handles into an array 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) $aListView[1] = $listview_ta ; Put handles into an array 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, 3, 4 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) 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 ; Set clicked listview handle as passed in $fDblClk $hListView = $fDblClk $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) ; Check the listviews For $i = 0 To 1 If HWnd(DllStructGetData($tNMHDR, "hWndFrom")) = $aListView[$i] Then If DllStructGetData($tNMHDR, "Code") = $NM_DBLCLK Then $aLV_Click_Info = _GUICtrlListView_SubItemHitTest($aListView[$i]) ; 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 = $aListView[$i] ; return the handle of the Listview that was doubleclicked EndIf EndIf EndIf Next Return $GUI_RUNDEFMSG EndFuncMost of this script is my coding - you need to understand how and why the script works or you will never progress. Go over this new script carefull and ASK if there is anything you do not understand - I will not be here every time you have a problem. M23  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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Â
misterDee Posted March 13, 2011 Author Posted March 13, 2011 Most of this script is my coding - you need to understand how and why the script works or you will never progress. Go over this new script carefull and ASK if there is anything you do not understand - I will not be here every time you have a problem. M23I had experimented a bit with the ListView in array but see now where I've made ​​the mistake, thank you for the support, I am going to do it myself, at least I understand better now how it worksMisterdee
JAFN Posted April 29, 2011 Posted April 29, 2011 (edited) M23, I'm trying to adapt this into my own code as well. Not working on a combobox, just need to capture a double click on the listview. What I have: expandcollapse popup; 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") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ; Large block of code While 1 If $DataChange <> $holdDataState Then If $DataChange Then GUICtrlSetState($Refresh, $GUI_ENABLE) Else GUICtrlSetState($Refresh, $GUI_DISABLE) EndIf $holdDataState = $DataChange EndIf If $fDblClk Then $fDblClk = False KeyTap(@ScriptLineNumber) EndIf ; Look for GUI events Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ;larger block of code 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")) = $LVid And DllStructGetData($tNMHDR, "Code") = $NM_DBLCLK Then $aLV_Click_Info = _GUICtrlListView_SubItemHitTest($LVid) ; 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 Is not trigger my test sound. It looked fairly straight forward even if I didn't understand all of WM_Notify. Can you help me? I'm almost done with this thing but I'm down to the stuff I haven't been able to make work. Edited April 29, 2011 by JAFN [size="2"]The second mouse gets the cheese[/size]
Jayson Posted April 29, 2011 Posted April 29, 2011 @JAFN : This might help you expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <Misc.au3> Global $aLV_Click_Info, $hTmp_Edit = 0, $fDblClk = False $hGUI = GUICreate("Test GUI", 300, 200) $hListView = _GUICtrlListView_Create($hGUI, "Items|SubItems", 10, 10, 280, 180) For $i = 1 To 10 _GUICtrlListView_AddItem($hListView, "Item " & $i) _GUICtrlListView_AddSubItem($hListView, $i - 1, "SubItems" & $i, 1) Next GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 If $hTmp_Edit <> 0 Then ; If a temporary edit exists If _IsPressed("0D") Then ; If ENTER pressed $sText = GUICtrlRead($hTmp_Edit) ; Set label to edit content _GUICtrlListView_SetItemText($hListView, $aLV_Click_Info[0], $sText, $aLV_Click_Info[1]) GUICtrlDelete($hTmp_Edit) ; Delete temporary edit $hTmp_Edit = 0 EndIf EndIf If $fDblClk Then ; If an item was double clicked $fDblClk = False GUICtrlDelete($hTmp_Edit) ; Delete any existing temporary edits $sTmp_Text = _GUICtrlListView_GetItemText($hListView, $aLV_Click_Info[0], $aLV_Click_Info[1]) ; Read current text of clicked label Switch $aLV_Click_Info[1] ; Get label position 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 $hTmp_Edit = GUICtrlCreateEdit($sTmp_Text, $aLV_Rect_Info[0] + 13, $aLV_Rect_Info[1] + 10, $aLV_Rect_Info[2] - $aLV_Rect_Info[0], $aLV_Rect_Info[3] - $aLV_Rect_Info[1], 0) ; Create temporary edit GUICtrlSetState($hTmp_Edit, $GUI_FOCUS) EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_DBLCLK $aLV_Click_Info = _GUICtrlListView_SubItemHitTest($hListView) If $aLV_Click_Info[0] <> -1 Then $fDblClk = True EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY
JAFN Posted April 29, 2011 Posted April 29, 2011 @JAFN : This might help you expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <Misc.au3> Global $aLV_Click_Info, $hTmp_Edit = 0, $fDblClk = False $hGUI = GUICreate("Test GUI", 300, 200) $hListView = _GUICtrlListView_Create($hGUI, "Items|SubItems", 10, 10, 280, 180) For $i = 1 To 10 _GUICtrlListView_AddItem($hListView, "Item " & $i) _GUICtrlListView_AddSubItem($hListView, $i - 1, "SubItems" & $i, 1) Next GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 If $hTmp_Edit <> 0 Then ; If a temporary edit exists If _IsPressed("0D") Then ; If ENTER pressed $sText = GUICtrlRead($hTmp_Edit) ; Set label to edit content _GUICtrlListView_SetItemText($hListView, $aLV_Click_Info[0], $sText, $aLV_Click_Info[1]) GUICtrlDelete($hTmp_Edit) ; Delete temporary edit $hTmp_Edit = 0 EndIf EndIf If $fDblClk Then ; If an item was double clicked $fDblClk = False GUICtrlDelete($hTmp_Edit) ; Delete any existing temporary edits $sTmp_Text = _GUICtrlListView_GetItemText($hListView, $aLV_Click_Info[0], $aLV_Click_Info[1]) ; Read current text of clicked label Switch $aLV_Click_Info[1] ; Get label position 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 $hTmp_Edit = GUICtrlCreateEdit($sTmp_Text, $aLV_Rect_Info[0] + 13, $aLV_Rect_Info[1] + 10, $aLV_Rect_Info[2] - $aLV_Rect_Info[0], $aLV_Rect_Info[3] - $aLV_Rect_Info[1], 0) ; Create temporary edit GUICtrlSetState($hTmp_Edit, $GUI_FOCUS) EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_DBLCLK $aLV_Click_Info = _GUICtrlListView_SubItemHitTest($hListView) If $aLV_Click_Info[0] <> -1 Then $fDblClk = True EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY I strip out the overhead. Everything looks straight forward. And then it doesn't work. sigh. Time to pack it in for the day. Code gets endangered after sunset. Thanks anyway. [size="2"]The second mouse gets the cheese[/size]
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