rootx Posted January 23, 2017 Author Posted January 23, 2017 Work perfect. THX Now I have to study your script.... One question again, how can I remove the dots in the edge?
Moderators Melba23 Posted January 23, 2017 Moderators Posted January 23, 2017 rootx, What dots in what edge? 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
rootx Posted January 23, 2017 Author Posted January 23, 2017 4 minutes ago, Melba23 said: rootx, What dots in what edge? M23 !! sorry, I meant the border around the selected item.
Moderators Melba23 Posted January 23, 2017 Moderators Posted January 23, 2017 rootx, My _NoFocusLines UDF will do the trick for button, sllder, radio and checkbox controls, but I have never tried to do the same for a ListView. Not a trivial task in my opinion. M23 rootx 1 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
LarsJ Posted January 24, 2017 Posted January 24, 2017 If you know how it's close to being trivial. This is the example for GUICtrlCreateListView in the help file: expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Example() Func Example() GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES) GUISetBkColor(0x00E0FFFF) ; will change background color Local $idListview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150) ;,$LVS_SORTDESCENDING) Local $idButton = GUICtrlCreateButton("Remove dotted focus rectangle", 10, 170, 200, 20) Local $idItem1 = GUICtrlCreateListViewItem("item2|col22|col23", $idListview) Local $idItem2 = GUICtrlCreateListViewItem("item1|col12|col13", $idListview) Local $idItem3 = GUICtrlCreateListViewItem("item3|col32|col33", $idListview) GUICtrlCreateInput("", 20, 200, 150) GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping GUISetState(@SW_SHOW) GUICtrlSetData($idItem2, "ITEM1") GUICtrlSetData($idItem3, "||COL33") GUICtrlDelete($idItem1) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton If GUICtrlRead($idButton) = "Remove dotted focus rectangle" Then GUICtrlSetData( $idButton, "Add dotted focus rectangle" ) GUICtrlSendMsg( $idListview, $WM_CHANGEUISTATE, 65537, 0 ) ; 65537 = _WinAPI_MakeLong( 1, 1 ), 1 = UIS_SET, 1 = UISF_HIDEFOCUS Else GUICtrlSetData( $idButton, "Remove dotted focus rectangle" ) GUICtrlSendMsg( $idListview, $WM_CHANGEUISTATE, 65538, 0 ) ; 65538 = _WinAPI_MakeLong( 2, 1 ), 2 = UIS_CLEAR, 1 = UISF_HIDEFOCUS EndIf Case $idListview MsgBox($MB_SYSTEMMODAL, "listview", "clicked=" & GUICtrlGetState($idListview), 2) EndSwitch WEnd EndFunc ;==>Example Select an item and click empty space in the listview to see the dotted focus rectangle. Click the button. Repeat select item and click empty space. WM_CHANGEUISTATE. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
Moderators Melba23 Posted January 24, 2017 Moderators Posted January 24, 2017 LarsJ, Nice to be proved wrong - yet again! 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
rootx Posted January 25, 2017 Author Posted January 25, 2017 On 24/1/2017 at 3:59 PM, LarsJ said: If you know how it's close to being trivial. This is the example for GUICtrlCreateListView in the help file: expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Example() Func Example() GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES) GUISetBkColor(0x00E0FFFF) ; will change background color Local $idListview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150) ;,$LVS_SORTDESCENDING) Local $idButton = GUICtrlCreateButton("Remove dotted focus rectangle", 10, 170, 200, 20) Local $idItem1 = GUICtrlCreateListViewItem("item2|col22|col23", $idListview) Local $idItem2 = GUICtrlCreateListViewItem("item1|col12|col13", $idListview) Local $idItem3 = GUICtrlCreateListViewItem("item3|col32|col33", $idListview) GUICtrlCreateInput("", 20, 200, 150) GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping GUISetState(@SW_SHOW) GUICtrlSetData($idItem2, "ITEM1") GUICtrlSetData($idItem3, "||COL33") GUICtrlDelete($idItem1) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton If GUICtrlRead($idButton) = "Remove dotted focus rectangle" Then GUICtrlSetData( $idButton, "Add dotted focus rectangle" ) GUICtrlSendMsg( $idListview, $WM_CHANGEUISTATE, 65537, 0 ) ; 65537 = _WinAPI_MakeLong( 1, 1 ), 1 = UIS_SET, 1 = UISF_HIDEFOCUS Else GUICtrlSetData( $idButton, "Remove dotted focus rectangle" ) GUICtrlSendMsg( $idListview, $WM_CHANGEUISTATE, 65538, 0 ) ; 65538 = _WinAPI_MakeLong( 2, 1 ), 2 = UIS_CLEAR, 1 = UISF_HIDEFOCUS EndIf Case $idListview MsgBox($MB_SYSTEMMODAL, "listview", "clicked=" & GUICtrlGetState($idListview), 2) EndSwitch WEnd EndFunc ;==>Example Select an item and click empty space in the listview to see the dotted focus rectangle. Click the button. Repeat select item and click empty space. WM_CHANGEUISTATE. Thx, I tried the Melba UDF "NoFocusLines.au3" without success, now I tried your trick in my script but it does not work, I used it after Case $NM_CLICK, but the dotted focus persist.
Moderators Melba23 Posted January 25, 2017 Moderators Posted January 25, 2017 rootx, Quote I tried the Melba UDF "NoFocusLines.au3" without success I told you above that: Quote My _NoFocusLines UDF will do the trick for button, sllder, radio and checkbox controls So where did you get the idea that it could ever work on a ListView? 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
rootx Posted January 25, 2017 Author Posted January 25, 2017 8 minutes ago, Melba23 said: rootx, I told you above that: So where did you get the idea that it could ever work on a ListView? M23 Right, your UDF works perfectly with other elements, and I used it on my script, THX for share your UDF Melba. I meant that I could not resolve the listview with the LarsJ trick. THX you guys.
Moderators Melba23 Posted January 25, 2017 Moderators Posted January 25, 2017 rootx, Sorry for the misunderstanding - glad you found my UDF useful. Did LarsJ's example work for you? If so, then post the code where you tried to integrate it into your script and perhaps we can spot where it is going wrong. 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
rootx Posted February 1, 2017 Author Posted February 1, 2017 On 25/1/2017 at 9:20 PM, Melba23 said: rootx, Sorry for the misunderstanding - glad you found my UDF useful. Did LarsJ's example work for you? If so, then post the code where you tried to integrate it into your script and perhaps we can spot where it is going wrong. M23 Sorry for the delay, I was sick, I need help to understand how to use LarsJ trick on my code, I tried without success, THX thanks for your patience. Look at Line 138. expandcollapse popup#include <Misc.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <ListBoxConstants.au3> #include <GuiListBox.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include <File.au3> #include <FileConstants.au3> #include <StaticConstants.au3> #include <GuiImageList.au3> #include <GuiStatusBar.au3> #include <WinAPI.au3> #include <GDIPlus.au3> #include <Date.au3> #include <IE.au3> #include "GUIListViewEx.au3" HotKeySet("{ESC}", "On_Exit") Global $bChanged ;Graphics Global $icod = @ScriptDir & "\img\defico.jpg" Global $bg = @ScriptDir & "\img\def.jpg" Global $ini = @ScriptDir & "\ini.ini" For $z = 1 to 4 IniWriteSection($ini,@ScriptDir&"\data\"&$z,"") Next $sect = IniReadSectionNames($ini) For $s = 1 To UBound($sect) - 1 IniWrite($ini,$sect[$s],"name",$s) IniWrite($ini,$sect[$s],"img",@ScriptDir&"\img\"&$s&".jpg") IniWrite($ini,$sect[$s],"icon",@ScriptDir&"\ico\"&$s&".ico") IniWrite($ini,$sect[$s],"background",@ScriptDir&"\img\"&$s&".jpg") Next $GUIH="600" $GUIW="1024" $LsX="172" $LsY="33" $LsW="340" $LsH="481" $Xcolor = "0x0000FFFF" $Xfcolor = "0x0000FFFF" _GDIPlus_Startup() $Form1 = GUICreate("My LIB", 1024, 600, -1, -1) GUICtrlSetDefColor($Xfcolor) GUICtrlSetDefBkColor($Xcolor) $Pic2 = GUICtrlCreatePic($bg, 820, 10, 200, 200, BitOR($GUI_SS_DEFAULT_PIC, $SS_CENTERIMAGE, $SS_SUNKEN, $WS_BORDER)) ;Create listview $hListView = _GUICtrlListView_Create($Form1, "", 0, 0, 320, 600) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_AUTOARRANGE, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER, $LVS_EX_SUBITEMIMAGES)) ; block resizing of columns ControlDisable($Form1, "", HWnd(_GUICtrlListView_GetHeader($hListView))) ;_GUICtrlListView_SetBkColor($hListView, $Xcolor) ;_GUICtrlListView_SetTextBkColor($hListView, $Xcolor) ;_GUICtrlListView_SetTextColor($hListView, 0x0000000) ;Add columns _GUICtrlListView_InsertColumn($hListView, 0, "", 320) _GUICtrlListView_InsertColumn($hListView, 1, "Path", 0) _GUIListViewEx_MsgRegister(False) ;<--------------------------------------- GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST') GUISetState(@SW_SHOW) ;Slide Effect Global $hGfx = _GDIPlus_GraphicsCreateFromHWND($Form1) ;clip control elements Global $hRegion = _GDIPlus_RegionCreateFromRect(0, 0, $guiw, $guih) Global $hChild = _WinAPI_GetWindow($Form1, $GW_CHILD) Global $aRect Do $aRect = ControlGetPos($hChild, "", 0) _GDIPlus_RegionCombineRect($hRegion, $aRect[0], $aRect[1], $aRect[2], $aRect[3], 3) $hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT) Until Not $hChild _GDIPlus_GraphicsSetClipRegion($hGfx, $hRegion) _GDIPlus_RegionDispose($hRegion) Global $hBmp1 = _GDIPlus_ImageLoadFromFile($bg) _GDIPlus_GraphicsDrawImageRect($hGfx, $hBmp1, 0, 0, $guiw, $guih) read() _GUICtrlListView_RegisterSortCallBack($hListView) While 1 $aMsg = GUIGetMsg(1) Switch $aMsg[1] Case $Form1 Switch $aMsg[0] Case $GUI_EVENT_CLOSE _GDIPlus_ImageDispose($hBmp1) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_Shutdown() EndSwitch EndSwitch WEnd ; ======================================================== ; This thing is responcible for click events ; ======================================================== Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CLICK ; The user has clicked the left mouse button within the control Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $Index = DllStructGetData($tInfo, "Index") If DllStructGetData($tInfo, "Index") = -1 Then ;ConsoleWrite("no item" & @CRLF) Else GUICtrlSendMsg($hListView, $WM_CHANGEUISTATE, 65537, 0 );<--------------------------------------------??? Local $iItemText = _GUICtrlListView_GetItemText($hListView, DllStructGetData($tInfo, "Index"), 1) $pics = IniRead($ini, $iItemText, "img", "") If FileExists($pics) Then GUICtrlSetImage($Pic2, $pics) Else GUICtrlSetImage($Pic2, $icod) EndIf $item = StringSplit(_GUICtrlListView_GetItemTextString($hListView, $Index), '|') $itemx = $item[1] $item2 = IniRead($ini, $iItemText, "background", "") Local $n = 1, $guihx = $guih + 50 If FileExists($item2) Then Local $hBmp2 = _GDIPlus_ImageLoadFromFile(IniRead($ini, $iItemText, "background", "")) For $x = -$guiw To 0 Step 50 _GDIPlus_GraphicsDrawImageRect($hGfx, $hBmp2, 0, $x, $guiw, $guihx) Next _GDIPlus_ImageDispose($hBmp2) Else Local $hBmp2 = _GDIPlus_ImageLoadFromFile($bg) For $x = -$guiw To 0 Step 50 _GDIPlus_GraphicsDrawImageRect($hGfx, $hBmp2, 0, $x, $guiw, $guihx) Next _GDIPlus_ImageDispose($hBmp2) EndIf EndIf Case $LVN_KEYDOWN $tInfo = DllStructCreate($tagNMLVKEYDOWN, $ilParam) $iKey = DllStructGetData($tInfo, "VKey") ; Get current selection $aLastSel = StringSplit(_GUIListViewEx_GetLastSelectedItem(), "|") Switch $iKey Case 38 ; Move up unless at top $iCurrItem = $aLastSel[2] - 1 If $iCurrItem < 0 Then $iCurrItem = 0 EndIf _GUICtrlListView_ClickItem($hWndFrom, $iCurrItem) Case 40 ; Move down unless at bottom $iCurrItem = $aLastSel[2] + 1 If $iCurrItem >= _GUICtrlListView_GetItemCount($hWndFrom) Then $iCurrItem = _GUICtrlListView_GetItemCount($hWndFrom) - 1 EndIf _GUICtrlListView_ClickItem($hWndFrom, $iCurrItem) EndSwitch EndSwitch EndSwitch $iRet = _GUIListViewEx_WM_NOTIFY_Handler($hWnd, $iMsg, $iwParam, $ilParam);<--------------------------------------- Return $iRet;<--------------------------------------- Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam) Return $HTCAPTION EndFunc ;==>WM_NCHITTEST Func On_Exit() Exit EndFunc ;==>On_Exit Func read() Local $tot = 0 If FileExists($ini) Then $hImage = _GUIImageList_Create(48, 48, 5, 1) _GDIPlus_Startup() $aArrays = IniReadSectionNames($ini) _ArrayColInsert($aArrays, 1) For $s = 1 To UBound($aArrays) - 1 $aArrays[$s][1] = StringRegExp($aArrays[$s][0], '.*\\(.*)\\', 1)[0] Next _ArrayColDelete($aArrays, 1, True) If Not @error Then For $i = 1 To UBound($aArrays) - 1 $n = IniRead($ini, $aArrays[$i], "name", "") $z = IniRead($ini, $aArrays[$i], "icon", "") ;load icon and upscale the icon to 48x48 pixels $hBitmap = _GDIPlus_BitmapCreateFromFile($z) $hBitmap_scaled = _GDIPlus_ImageResize($hBitmap, 48, 48) $hBitmap_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_scaled) _GDIPlus_BitmapDispose($hBitmap_scaled) _GDIPlus_BitmapDispose($hBitmap) $ico = _GUIImageList_Add($hImage, $hBitmap_GDI) _GUICtrlListView_SetImageList($hListView, $hImage, 1) _GUICtrlListView_AddItem($hListView, $n, $ico) _GUICtrlListView_AddSubItem($hListView, $i - 1, $aArrays[$i], 1) $tot += 1 Next $aLVArray = _GUIListViewEx_ReadToArray($hListView);<--------------------------------------- $iLV_Index = _GUIListViewEx_Init($hListView, $aLVArray, 0, 0, True, 32 + 512);<--------------------------------------- ; Set required colours for ListView elements - change = pink field when selected;<--------------------------------------- Local $aSelCol[4] = [Default, Default, Default, "0xFFCCCC"];<--------------------------------------- _GUIListViewEx_SetDefColours($iLV_Index, $aSelCol);<--------------------------------------- _GDIPlus_Shutdown() EndIf EndIf EndFunc ;==>read Func _GUIListViewEx_GetLastSelectedItem($iLV_Index = 0) ; Check valid index Switch $iLV_Index Case 1 To $aGLVEx_Data[0][0] ; Valid index Case Else ; Get active ListView $iLV_Index = _GUIListViewEx_GetActive() ; If no ListView active If $iLV_Index = 0 Then Return SetError(1, 0, "") EndSwitch ; Read last selected item Local $iRow = $aGLVEx_Data[$iLV_Index][20] Local $iCol = $aGLVEx_Data[$iLV_Index][21] ; Check selection has been made If $iRow = -1 Or $iCol = -1 Then Return SetError(2, 0, "") ; Return selection details Return $iLV_Index & "|" & $iRow & "|" & $iCol EndFunc
Moderators Melba23 Posted February 1, 2017 Moderators Posted February 1, 2017 rootx, Firstly you are creating the ListView using the UDF, so you cannot use GUICtrlSendMsg - the creation function returns a handle and not a ControlID - you need to use _SendMessage instead. Here is your script amended to use a HotKey to toggle the focus lines: expandcollapse popup#include <Misc.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <ListBoxConstants.au3> #include <GuiListBox.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include <File.au3> #include <FileConstants.au3> #include <StaticConstants.au3> #include <GuiImageList.au3> #include <GuiStatusBar.au3> #include <WinAPI.au3> #include <GDIPlus.au3> #include <Date.au3> #include <IE.au3> #include "GUIListViewEx.au3" HotKeySet("{ESC}", "On_Exit") HotKeySet("^f", "_FocusSwitch") Global $fFocus = False Global $bChanged ;Graphics Global $icod = @ScriptDir & "\img\defico.jpg" Global $bg = @ScriptDir & "\img\def.jpg" Global $ini = @ScriptDir & "\ini.ini" For $z = 1 to 4 IniWriteSection($ini,@ScriptDir&"\data\"&$z,"") Next $sect = IniReadSectionNames($ini) For $s = 1 To UBound($sect) - 1 IniWrite($ini,$sect[$s],"name",$s) IniWrite($ini,$sect[$s],"img",@ScriptDir&"\img\"&$s&".jpg") IniWrite($ini,$sect[$s],"icon",@ScriptDir&"\ico\"&$s&".ico") IniWrite($ini,$sect[$s],"background",@ScriptDir&"\img\"&$s&".jpg") Next $GUIH="600" $GUIW="1024" $LsX="172" $LsY="33" $LsW="340" $LsH="481" $Xcolor = "0x0000FFFF" $Xfcolor = "0x0000FFFF" _GDIPlus_Startup() $Form1 = GUICreate("My LIB", 1024, 600, -1, -1) GUICtrlSetDefColor($Xfcolor) GUICtrlSetDefBkColor($Xcolor) $Pic2 = GUICtrlCreatePic($bg, 820, 10, 200, 200, BitOR($GUI_SS_DEFAULT_PIC, $SS_CENTERIMAGE, $SS_SUNKEN, $WS_BORDER)) ;Create listview $hListView = _GUICtrlListView_Create($Form1, "", 0, 0, 320, 600) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_AUTOARRANGE, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER, $LVS_EX_SUBITEMIMAGES)) ; block resizing of columns ControlDisable($Form1, "", HWnd(_GUICtrlListView_GetHeader($hListView))) ;_GUICtrlListView_SetBkColor($hListView, $Xcolor) ;_GUICtrlListView_SetTextBkColor($hListView, $Xcolor) ;_GUICtrlListView_SetTextColor($hListView, 0x0000000) ;Add columns _GUICtrlListView_InsertColumn($hListView, 0, "", 320) _GUICtrlListView_InsertColumn($hListView, 1, "Path", 0) _GUIListViewEx_MsgRegister(False) ;<--------------------------------------- GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST') GUISetState(@SW_SHOW) ;Slide Effect Global $hGfx = _GDIPlus_GraphicsCreateFromHWND($Form1) ;clip control elements Global $hRegion = _GDIPlus_RegionCreateFromRect(0, 0, $guiw, $guih) Global $hChild = _WinAPI_GetWindow($Form1, $GW_CHILD) Global $aRect Do $aRect = ControlGetPos($hChild, "", 0) _GDIPlus_RegionCombineRect($hRegion, $aRect[0], $aRect[1], $aRect[2], $aRect[3], 3) $hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT) Until Not $hChild _GDIPlus_GraphicsSetClipRegion($hGfx, $hRegion) _GDIPlus_RegionDispose($hRegion) Global $hBmp1 = _GDIPlus_ImageLoadFromFile($bg) _GDIPlus_GraphicsDrawImageRect($hGfx, $hBmp1, 0, 0, $guiw, $guih) read() _GUICtrlListView_RegisterSortCallBack($hListView) While 1 $aMsg = GUIGetMsg(1) Switch $aMsg[1] Case $Form1 Switch $aMsg[0] Case $GUI_EVENT_CLOSE _GDIPlus_ImageDispose($hBmp1) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_Shutdown() EndSwitch EndSwitch WEnd Func _FocusSwitch() $fFocus = Not $fFocus If $fFocus Then _SendMessage($hListView, $WM_CHANGEUISTATE, 65537, 0) Else _SendMessage($hListView, $WM_CHANGEUISTATE, 65538, 0) EndIf EndFunc ; ======================================================== ; This thing is responcible for click events ; ======================================================== Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CLICK ; The user has clicked the left mouse button within the control Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $Index = DllStructGetData($tInfo, "Index") If DllStructGetData($tInfo, "Index") = -1 Then ;ConsoleWrite("no item" & @CRLF) Else ;GUICtrlSendMsg($hListView, $WM_CHANGEUISTATE, 65537, 0 );<--------------------------------------------??? Local $iItemText = _GUICtrlListView_GetItemText($hListView, DllStructGetData($tInfo, "Index"), 1) $pics = IniRead($ini, $iItemText, "img", "") If FileExists($pics) Then GUICtrlSetImage($Pic2, $pics) Else GUICtrlSetImage($Pic2, $icod) EndIf $item = StringSplit(_GUICtrlListView_GetItemTextString($hListView, $Index), '|') $itemx = $item[1] $item2 = IniRead($ini, $iItemText, "background", "") Local $n = 1, $guihx = $guih + 50 If FileExists($item2) Then Local $hBmp2 = _GDIPlus_ImageLoadFromFile(IniRead($ini, $iItemText, "background", "")) For $x = -$guiw To 0 Step 50 _GDIPlus_GraphicsDrawImageRect($hGfx, $hBmp2, 0, $x, $guiw, $guihx) Next _GDIPlus_ImageDispose($hBmp2) Else Local $hBmp2 = _GDIPlus_ImageLoadFromFile($bg) For $x = -$guiw To 0 Step 50 _GDIPlus_GraphicsDrawImageRect($hGfx, $hBmp2, 0, $x, $guiw, $guihx) Next _GDIPlus_ImageDispose($hBmp2) EndIf EndIf Case $LVN_KEYDOWN $tInfo = DllStructCreate($tagNMLVKEYDOWN, $ilParam) $iKey = DllStructGetData($tInfo, "VKey") ; Get current selection $aLastSel = StringSplit(_GUIListViewEx_GetLastSelectedItem(), "|") Switch $iKey Case 38 ; Move up unless at top $iCurrItem = $aLastSel[2] - 1 If $iCurrItem < 0 Then $iCurrItem = 0 EndIf _GUICtrlListView_ClickItem($hWndFrom, $iCurrItem) Case 40 ; Move down unless at bottom $iCurrItem = $aLastSel[2] + 1 If $iCurrItem >= _GUICtrlListView_GetItemCount($hWndFrom) Then $iCurrItem = _GUICtrlListView_GetItemCount($hWndFrom) - 1 EndIf _GUICtrlListView_ClickItem($hWndFrom, $iCurrItem) EndSwitch EndSwitch EndSwitch $iRet = _GUIListViewEx_WM_NOTIFY_Handler($hWnd, $iMsg, $iwParam, $ilParam);<--------------------------------------- Return $iRet;<--------------------------------------- Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam) Return $HTCAPTION EndFunc ;==>WM_NCHITTEST Func On_Exit() Exit EndFunc ;==>On_Exit Func read() Local $tot = 0 If FileExists($ini) Then $hImage = _GUIImageList_Create(48, 48, 5, 1) _GDIPlus_Startup() $aArrays = IniReadSectionNames($ini) _ArrayColInsert($aArrays, 1) For $s = 1 To UBound($aArrays) - 1 $aArrays[$s][1] = StringRegExp($aArrays[$s][0], '.*\\(.*)\\', 1)[0] Next _ArrayColDelete($aArrays, 1, True) If Not @error Then For $i = 1 To UBound($aArrays) - 1 $n = IniRead($ini, $aArrays[$i], "name", "") $z = IniRead($ini, $aArrays[$i], "icon", "") ;load icon and upscale the icon to 48x48 pixels $hBitmap = _GDIPlus_BitmapCreateFromFile($z) $hBitmap_scaled = _GDIPlus_ImageResize($hBitmap, 48, 48) $hBitmap_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_scaled) _GDIPlus_BitmapDispose($hBitmap_scaled) _GDIPlus_BitmapDispose($hBitmap) $ico = _GUIImageList_Add($hImage, $hBitmap_GDI) _GUICtrlListView_SetImageList($hListView, $hImage, 1) _GUICtrlListView_AddItem($hListView, $n, $ico) _GUICtrlListView_AddSubItem($hListView, $i - 1, $aArrays[$i], 1) $tot += 1 Next $aLVArray = _GUIListViewEx_ReadToArray($hListView);<--------------------------------------- $iLV_Index = _GUIListViewEx_Init($hListView, $aLVArray, 0, 0, True, 32 + 512);<--------------------------------------- ; Set required colours for ListView elements - change = pink field when selected;<--------------------------------------- Local $aSelCol[4] = [Default, Default, Default, "0xFFCCCC"];<--------------------------------------- _GUIListViewEx_SetDefColours($iLV_Index, $aSelCol);<--------------------------------------- _GDIPlus_Shutdown() EndIf EndIf EndFunc ;==>read Func _GUIListViewEx_GetLastSelectedItem($iLV_Index = 0) ; Check valid index Switch $iLV_Index Case 1 To $aGLVEx_Data[0][0] ; Valid index Case Else ; Get active ListView $iLV_Index = _GUIListViewEx_GetActive() ; If no ListView active If $iLV_Index = 0 Then Return SetError(1, 0, "") EndSwitch ; Read last selected item Local $iRow = $aGLVEx_Data[$iLV_Index][20] Local $iCol = $aGLVEx_Data[$iLV_Index][21] ; Check selection has been made If $iRow = -1 Or $iCol = -1 Then Return SetError(2, 0, "") ; Return selection details Return $iLV_Index & "|" & $iRow & "|" & $iCol EndFunc There is fairly fundamental difference between handles and ControlIDs - I have explained it many times before - and you really need to be sure you understand it. Please ask if you have any questions. M23 rootx 1 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
rootx Posted February 1, 2017 Author Posted February 1, 2017 Thx, your post explains very well this important difference, now I understand.
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