WildByDesign Posted 3 hours ago Posted 3 hours ago I am trying to do some work on editing labels in a ListView. It's going to be related to file system stuff such as filenames and folders. So I want to disallow a label edit if the rename (label edit) is blank. I will likely have to check for other things as well such as characters that are not allowed in a filename or folder name. Problem: The example that I am following uses DllStructCreate and DllStructGetData to retrieve the Text of the changed label name to determine whether it is blank and so on. The problem with the example is that it is only returning the very first character. That, at the very least, allows me to check if the new text is blank or not. But it would not allow me to parse it any further to determine other filename or folder name character rules and such. I assume that the problem is in the $tBuffer line where it is only pulling the first character. My goal would be to retrieve the full text of the new label text to determine further course of action. Thank you so much for any assistance with this. Example: expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> Global $g_hListView, $idListview Example() Func Example() Local $hGui $hGui = GUICreate("ListView Edit Labels", 400, 300, Default, Default, Default, $WS_EX_CLIENTEDGE) $idListview = GUICtrlCreateListView("Column", 0, 0, 400, 300, BitOR($LVS_SHOWSELALWAYS, $LVS_EDITLABELS), BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) $g_hListView = GUICtrlGetHandle($idListview) GUISetState(@SW_SHOW) ; Add items GUICtrlCreateListViewItem("item1", $idListview) GUICtrlCreateListViewItem("item2", $idListview) GUICtrlCreateListViewItem("item3", $idListview) ; Monitor the WM_NOTIFY message. GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tText, $hWndListView = $g_hListView If Not IsHWnd($g_hListView) Then $hWndListView = GUICtrlGetHandle($g_hListView) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $LVN_BEGINLABELEDITA, $LVN_BEGINLABELEDITW ; Start of label editing for an item Return False ; Allow the user to edit the label Case $LVN_ENDLABELEDITA, $LVN_ENDLABELEDITW ; The end of label editing for an item $tText = DllStructCreate($tagNMLVDISPINFO, $lParam) Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tText, "TextMax") & "]", DllStructGetData($tText, "Text")) Local $sTextRet = DllStructGetData($tBuffer, "Text") ConsoleWrite("text after: " & DllStructGetData($tBuffer, "Text") & @CRLF) If $sTextRet <> "" Then Return True ; allow label edit Else Return False ; disallow label edit since text was blank EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY
Nine Posted 1 hour ago Posted 1 hour ago "char" <> "wchar"... SOLVE-SMART 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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