jakalspop 0 Posted October 14, 2010 how to check if user selecte item form listview or not the right menu will enable or disable Share this post Link to post Share on other sites
water 2,420 Posted October 14, 2010 You could use _GUICtrlListView_GetSelectedCount() to get the number of selected items. Or _GUICtrlListView_GetSelectedIndices() to get the indices of selected item(s). My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2021-04-14 - Version 1.5.3.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2021-04-13 - Version 1.6.4.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (NEW 2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
jakalspop 0 Posted October 14, 2010 thank but how enable or disable menu item Share this post Link to post Share on other sites
water 2,420 Posted October 15, 2010 Please check this post. I've taken this code snippet for my own scripts and it works great. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2021-04-14 - Version 1.5.3.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2021-04-13 - Version 1.6.4.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (NEW 2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
Yashied 242 Posted October 15, 2010 expandcollapse popup#Include <GUIConstantsEx.au3> #Include <GUIListView.au3> #Include <ListViewConstants.au3> #Include <WindowsConstants.au3> #Include <WinAPI.au3> Global $hForm, $hListView, $Dummy1, $Dummy2 Global $Accel[1][2] = [['{ENTER}', 0]] $Form = GUICreate('MyGUI', 400, 400) GUICtrlCreateListView('Column', 10, 10, 380, 380, BitOR($LVS_NOSORTHEADER, $LVS_SINGLESEL), $WS_EX_CLIENTEDGE) $hListView = GUICtrlGetHandle(-1) For $i = 0 To 9 _GUICtrlListView_AddItem($hListView, 'Item ' & $i) Next $Dummy1 = GUICtrlCreateDummy() $Dummy2 = GUICtrlCreateDummy() $Accel[0][1] = GUICtrlCreateDummy() GUISetAccelerators($Accel) GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY') GUISetState(@SW_SHOW) While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE ExitLoop Case $Dummy1 ConsoleWrite('Item' & GUICtrlRead($Dummy1) & ' - selected!' & @CR) Case $Dummy2 ConsoleWrite('Item' & GUICtrlRead($Dummy2) & ' - activated by double click!' & @CR) Case $Accel[0][1] If _WinAPI_GetFocus() = $hListView Then $Index = _GUICtrlListView_GetSelectedIndices($hListView) If $Index Then ConsoleWrite('Item' & $Index & ' - activated by ENTER!' & @CR) ; GUICtrlSendToDummy($Dummy2, Number($Index)) EndIf EndIf EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tNMITEMACTIVATE = DllStructCreate($tagNMITEMACTIVATE, $lParam) Local $hFrom = DllStructGetData($tNMITEMACTIVATE, 'hWndFrom') Local $Index = DllStructGetData($tNMITEMACTIVATE, 'Index') Local $ID = DllStructGetData($tNMITEMACTIVATE, 'Code') Switch $hFrom Case $hListView Switch $ID Case $LVN_ITEMACTIVATE GUICtrlSendToDummy($Dummy2, $Index) Case $LVN_ITEMCHANGED If (BitAND(DllStructGetData($tNMITEMACTIVATE, 'Changed'), $LVIF_STATE)) And (BitAND(DllStructGetData($tNMITEMACTIVATE, 'NewState'), $LVIS_SELECTED)) And (Not BitAND(DllStructGetData($tNMITEMACTIVATE, 'OldState'), $LVIS_FOCUSED)) Then GUICtrlSendToDummy($Dummy1, $Index) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY My UDFs:iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL HelperAnimated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF LibraryAppropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignmentMore... Share this post Link to post Share on other sites
jakalspop 0 Posted October 16, 2010 thank for example but i ready use this function for double click on tree Func MY_WM_NOTIFY($hWnd, $Msg, $wParam, $ilParam) Switch $wParam Case $regmanagers Local $tagNMHDR = DllStructCreate("int;int;int", $ilParam) If @error Then Return If DllStructGetData($tagNMHDR, 3) = $NM_DBLCLK Then $fDblClk = True Case $FILEmanagers1 Local $tagNMHDR = DllStructCreate("int;int;int", $ilParam) If @error Then Return If DllStructGetData($tagNMHDR, 3) = $NM_DBLCLK Then $fDblClk = True Case $Tre Local $tagNMHDR = DllStructCreate("int;int;int", $ilParam) If @error Then Return If DllStructGetData($tagNMHDR, 3) = $NM_DBLCLK Then $fDblClk = True EndSwitch EndFunc Share this post Link to post Share on other sites
Tvern 11 Posted October 16, 2010 You can just combine the contents of the two WM_Notify functions. Share this post Link to post Share on other sites
Tvern 11 Posted October 16, 2010 Paste the contents of your "MY_WM_NOTIFY" into Yashieds "WM_NOTIFY". Change $Msg to $iMsg, and $ilParam to $lParam. (change $tagNMHDR to something else while you're at it. It's already used by a Global Const) Check if it behaves as desired. Share this post Link to post Share on other sites
jakalspop 0 Posted October 17, 2010 i do that be for but it not work Share this post Link to post Share on other sites
Tvern 11 Posted October 17, 2010 Then post your attempt. Share this post Link to post Share on other sites
jakalspop 0 Posted October 17, 2010 (edited) ok like Func MY_WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tNMITEMACTIVATE = DllStructCreate($tagNMITEMACTIVATE, $lParam) Local $hFrom = DllStructGetData($tNMITEMACTIVATE, 'hWndFrom') Local $Index = DllStructGetData($tNMITEMACTIVATE, 'Index') Local $ID = DllStructGetData($tNMITEMACTIVATE, 'Code') Switch $wParam Case $regmanagers Local $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return If DllStructGetData($tagNMHDR, 3) = $NM_DBLCLK Then $fDblClk = True Case $FILEmanagers1 Local $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return If DllStructGetData($tagNMHDR, 3) = $NM_DBLCLK Then $fDblClk = True Case $Tre Local $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return If DllStructGetData($tagNMHDR, 3) = $NM_DBLCLK Then $fDblClk = True Case $listview Switch $ID Case $LVN_ITEMACTIVATE GUICtrlSendToDummy($Dummy2, $Index) Case $LVN_ITEMCHANGED If (BitAND(DllStructGetData($tNMITEMACTIVATE, 'Changed'), $LVIF_STATE)) And (BitAND(DllStructGetData($tNMITEMACTIVATE, 'NewState'), $LVIS_SELECTED)) And (Not BitAND(DllStructGetData($tNMITEMACTIVATE, 'OldState'), $LVIS_FOCUSED)) Then GUICtrlSendToDummy($Dummy1, $Index) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndSwitch EndFunc Edited October 17, 2010 by jakalspop Share this post Link to post Share on other sites
Tvern 11 Posted October 17, 2010 It's all good and well that you want to do things as effective as possible, but when you are combining two functions that work. It's best to first implement them in a way that is likely to work and then start rewriting it to make the code more effecient, or pretty. With this approach you could go from an embedded function call: Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tNMITEMACTIVATE = DllStructCreate($tagNMITEMACTIVATE, $lParam) Local $hFrom = DllStructGetData($tNMITEMACTIVATE, 'hWndFrom') Local $Index = DllStructGetData($tNMITEMACTIVATE, 'Index') Local $ID = DllStructGetData($tNMITEMACTIVATE, 'Code') Switch $hFrom Case $hListView Switch $ID Case $LVN_ITEMACTIVATE GUICtrlSendToDummy($Dummy2, $Index) Case $LVN_ITEMCHANGED If (BitAND(DllStructGetData($tNMITEMACTIVATE, 'Changed'), $LVIF_STATE)) And (BitAND(DllStructGetData($tNMITEMACTIVATE, 'NewState'), $LVIS_SELECTED)) And (Not BitAND(DllStructGetData($tNMITEMACTIVATE, 'OldState'), $LVIS_FOCUSED)) Then GUICtrlSendToDummy($Dummy1, $Index) EndIf EndSwitch EndSwitch MY_WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY To a crude copy paste: expandcollapse popupFunc WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) ;yashieds function Local $tNMITEMACTIVATE = DllStructCreate($tagNMITEMACTIVATE, $lParam) Local $hFrom = DllStructGetData($tNMITEMACTIVATE, 'hWndFrom') Local $Index = DllStructGetData($tNMITEMACTIVATE, 'Index') Local $ID = DllStructGetData($tNMITEMACTIVATE, 'Code') Switch $hFrom Case $hListView Switch $ID Case $LVN_ITEMACTIVATE GUICtrlSendToDummy($Dummy2, $Index) Case $LVN_ITEMCHANGED If (BitAND(DllStructGetData($tNMITEMACTIVATE, 'Changed'), $LVIF_STATE)) And (BitAND(DllStructGetData($tNMITEMACTIVATE, 'NewState'), $LVIS_SELECTED)) And (Not BitAND(DllStructGetData($tNMITEMACTIVATE, 'OldState'), $LVIS_FOCUSED)) Then GUICtrlSendToDummy($Dummy1, $Index) EndIf EndSwitch EndSwitch ;jakalspops function Switch $wParam Case $regmanagers Local $tNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return If DllStructGetData($tNMHDR, 3) = $NM_DBLCLK Then $fDblClk = True Case $FILEmanagers1 Local $tNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return If DllStructGetData($tNMHDR, 3) = $NM_DBLCLK Then $fDblClk = True Case $Tre Local $tNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return If DllStructGetData($tNMHDR, 3) = $NM_DBLCLK Then $fDblClk = True EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY To something like this: Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tNMITEMACTIVATE = DllStructCreate($tagNMITEMACTIVATE, $lParam) Local $hFrom = DllStructGetData($tNMITEMACTIVATE, 'hWndFrom') Local $ID = DllStructGetData($tNMITEMACTIVATE, 'Code') Switch $hFrom Case $hListView Switch $ID Case $LVN_ITEMACTIVATE GUICtrlSendToDummy($Dummy2, $Index) Case $LVN_ITEMCHANGED If (BitAND(DllStructGetData($tNMITEMACTIVATE, 'Changed'), $LVIF_STATE)) And (BitAND(DllStructGetData($tNMITEMACTIVATE, 'NewState'), $LVIS_SELECTED)) And (Not BitAND(DllStructGetData($tNMITEMACTIVATE, 'OldState'), $LVIS_FOCUSED)) Then GUICtrlSendToDummy($Dummy1, $Index) EndIf EndSwitch EndSwitch Switch $wParam Case $regmanagers, $FILEmanagers1, $Tre If $ID = $NM_DBLCLK Then $fDblClk = True EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Etc... None of those functions are tested, but this way you can usually pinpoint what you're doing wrong when combining functions. Another great tool is consolewriting values, to see if the values you're getting are what you'd expect. Share this post Link to post Share on other sites