Jump to content

WM_NOTIFY - Invalid variable


Recommended Posts

I have run into an issue when using the WM_NOTIFY function for editing the text in a listview. The problem is not on my machine, but on a coworkers box. When he tries to run the AU3 file on his box, he gets an error message saying that there are undefined variables ($LVN_BEGINLABELEDIT/$LVN_BEGINLABELEDITW)...

D:\Documents and Settings\guidpaug\Desktop\New Folder (2)\Daily E-mail.au3 (1244) : ==> Variable used without being declared.:

Case $LVN_BEGINLABELEDIT, $LVN_BEGINLABELEDITW

All of the #includes are in the code, so that is not the issue. The only difference that I can see is that he is running Scite version 1.79 and I am running Scite version 1.78, but ??.

Has anyone seen this before or know what is going on with this?

Thanks,

James

List of the includes within the program:

#include <StructureConstants.au3>
#include <IE.au3>
#include <GuiComboBox.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>
#include <String.au3>
#include <GuiListView.au3>
#include <Misc.au3>
#include <GUIConstants.au3>
#include <GuiListBox.au3>
#include <GuiMenu.au3>
#include <WinAPI.au3>
#include <TipUpdate.au3>
#include <Date.au3>
#include <Array.au3>
#include <WinAPI.au3>
#include <File.au3>

WM_NOTIFY code section:

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $Option

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $hWndFrom
        Case GUICtrlGetHandle($ListEmail), GUICtrlGetHandle($ListTo), GUICtrlGetHandle($ListCC)
            Switch $iCode
                Case $LVN_BEGINLABELEDIT, $LVN_BEGINLABELEDITW ; Start of label editing for an item
                    ;Return False ; Allow the user to edit the label
                    Return True ; Prevent the user from editing the label
                Case $LVN_COLUMNCLICK ; A column was clicked
                    ; No return value
                Case $LVN_DELETEITEM ; An item is about to be deleted
                    ; No return value
                Case $LVN_ENDLABELEDIT, $LVN_ENDLABELEDITW ; The end of label editing for an item
                    $ListViewItem = _GUICtrlListView_SubItemHitTest($hWndFrom)
                    $tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam)
                    Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", DllStructGetData($tInfo, "Text"))
                    If StringLen(DllStructGetData($tBuffer, "Text")) And DllStructGetData($tBuffer, "Text") <> "0" Then
                        If DuplicateAddress(DllStructGetData($tBuffer, "Text")) = 1 Then
                            ReplaceAddressInAll(_GUICtrlListView_GetItemText($hWndFrom, DllStructGetData($tInfo, "Item")), DllStructGetData($tBuffer, "Text"))
                            UpdateSetup()
                            Return True
                        Else
                            MsgBox(0, "Duplicate E-mail Address", "This name already exists in the list" & @CRLF & "(Check E-mail Address, To and CC)")
                            Return False
                        EndIf
                    EndIf
                    ; If Text is not empty, return True to set the item's label to the edited text, return false to reject it
                    ; If Text is empty the return value is ignored
                Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                    ; No return value
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    ; No return value
                Case $NM_KILLFOCUS ; The control has lost the input focus
                    ; No return value
                Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
                    ;Return 1 ; not to allow the default processing
                    $ListViewItem = _GUICtrlListView_SubItemHitTest($hWndFrom)
                    If $ListViewItem[0] <> -1 Then $Option = _GUICtrlMenu_TrackPopupMenu(GUICtrlGetHandle($EmailContext), $FrmSetup, -1, -1, 1, 1, 2, 0)
                    If $Option = $EmailContextRename Then
                        _GUICtrlListView_EditLabel($hWndFrom, $ListViewItem[0])
                    ElseIf $Option = $EmailContextDelete And $hWndFrom = GUICtrlGetHandle($ListEmail) Then
                        RemoveAddress(_GUICtrlListView_GetItemText($hWndFrom, $ListViewItem[0]), 0)
                        UpdateSetup()
                    ElseIf $Option = $EmailContextDelete And ($hWndFrom = GUICtrlGetHandle($ListTo) Or $hWndFrom = GUICtrlGetHandle($ListCC)) Then
                        _GUICtrlListView_CopyItems($hWndFrom, GUICtrlGetHandle($ListEmail), "true")
                        _GUICtrlListView_SetColumnWidth(GUICtrlGetHandle($ListEmail), 0, $LVSCW_AUTOSIZE)
;~                      RemoveAddress(_GUICtrlListView_GetItemText($hWndFrom, $ListViewItem[0]), 1)
;~                      UpdateSetup()
                    EndIf
                    Return 0 ; allow the default processing
                Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
                    ; No return value
                Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
                    ; No return value
                Case $NM_SETFOCUS ; The control has received the input focus
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
Link to comment
Share on other sites

Why does the version of SciTe matter?

Unless you're hiding something from us then you should be more worried about that you have the same version of AutoIt.

MsgBox(262208, "AutoIt version is:", @AutoItVersion)
Link to comment
Share on other sites

  • Moderators

jbrady21,

The constants you are missing are in ListViewConstants.au3 for v3.3.2.0. I can only imagine that in an earlier version they were in another include which is why you do not have the problem. Are you both running the same version of Autoit?

M23

Edit: See I was beaten to it - that is what comes when i am trying to follow the Test match at the same time!

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

We are not both running the same versions of AutoIt (3.3.0.0 for me / 3.3.2.0 for him).

I will test out the suggestion from KaFu out (Replace $LVN_BEGINLABELEDIT with $LVN_BEGINLABELEDITA) and see where this gets me.

Thanks for the quick responses,

James

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...