SHARE
TWEET

code mẫu tam thời ContextMenu cho Listview

thanchet3 Mar 8th, 2019 (edited) 261 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <GUIConstantsEx.au3>
  2. #include <MsgBoxConstants.au3>
  3. #include <WindowsConstants.au3>
  4. #include <ListViewConstants.au3>
  5. #include <GuiListView.au3>
  6.  
  7. $iLVStyle = BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS)
  8. $iLVExtStyle = BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)
  9.  
  10. Example()
  11.  
  12. Func Example()
  13.     GUICreate("listview items", 220, 250, -1, -1, -1, $WS_EX_ACCEPTFILES)
  14.     GUISetBkColor(0x00E0FFFF) ; will change background color
  15.  
  16.     Local $idListview = GUICtrlCreateListView("col1      |col2|col3  ", 10, 10, 200, 150, $iLVStyle, $iLVExtStyle) ;,$LVS_SORTDESCENDING)
  17.     Local $idItem1 = GUICtrlCreateListViewItem("item1|col22|ON", $idListview)
  18.     Local $idItem2 = GUICtrlCreateListViewItem("item2|col12|OFF", $idListview)
  19.     Local $idItem3 = GUICtrlCreateListViewItem("item3|col32|ON", $idListview)
  20.     $Menu = GUICtrlCreateContextMenu($idListview)
  21.     $mDel = GUICtrlCreateMenuItem("Delete", $Menu)
  22. ;~  GUICtrlSetState(-1, $GUI_DISABLE)
  23.     $mEdit = GUICtrlCreateMenuItem("Edit", $Menu)
  24. ;~  GUICtrlSetState(-1, $GUI_DISABLE)
  25.     $mAdd = GUICtrlCreateMenuItem("Add", $Menu)
  26. ;~  GUICtrlSetState(-1, $GUI_DISABLE)
  27.     GUICtrlCreateMenuItem("", $Menu)
  28.     $mON = GUICtrlCreateMenuItem("ON", $Menu)
  29. ;~  GUICtrlSetState(-1, $GUI_DISABLE)
  30.     $mOFF = GUICtrlCreateMenuItem("OFF", $Menu)
  31. ;~  GUICtrlSetState(-1, $GUI_DISABLE)
  32.     GUISetState(@SW_SHOW)
  33.  
  34.     ; Loop until the user exits.
  35.     While 1
  36.         Switch GUIGetMsg()
  37.             Case $GUI_EVENT_CLOSE
  38.                 ExitLoop
  39.  
  40. ;~             Case $idButton
  41. ;~                 MsgBox($MB_SYSTEMMODAL, "listview item", GUICtrlRead(GUICtrlRead($idListview)), 2)
  42.  
  43.             Case $idListview
  44. ;~                 MsgBox($MB_SYSTEMMODAL, "listview", "clicked=" & GUICtrlGetState($idListview), 2)
  45.  
  46.         EndSwitch
  47.     WEnd
  48. EndFunc   ;==>Example
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top