Moving the edit control created when a ListView label edit starts
The MSDN docs state:
"When label editing begins, an edit control is created, positioned, and
initialized. Before it is displayed, the list view control sends its parent
window an LVN_BEGINLABELEDIT notification message.
To customize label editing, implement a handler for LVN_BEGINLABELEDIT and
have it send an LVM_GETEDITCONTROL message to the list view control. If a
label is being edited, the return value will be a handle to the edit
control. Use this handle to customize the edit control by sending the usual
So, I tried implementing this, only it does not seem to work. The MoveWindow
call succeeds, but the edit control does not move... the EditControl method
is just a thin wrapper for LVM_GETEDITCONTROL.
Private Declare Function MoveWindow Lib "user32" (ByVal hWnd As Long, _
ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As
Long, ByVal bRepaint As Long) _
Private Sub lvwSettings_BeforeLabelEdit(Item As dsListView.ListItem, Cancel
Dim hwndEdit As Long, rc As Long
hwndEdit = lvwSettings.EditControl
Debug.Print "hwndEdit := " & hwndEdit
rc = MoveWindow(hwndEdit, lvwSettings.ColumnHeaders(2).Left, Item.Top,
'// rc = MoveWindow(hwndEdit, 320, 200, 140, 130, 1)
MsgBox "rc := " & rc, vbInformation, "lvwSettings_BeforeLabelEdit"
I remember reading a VBPJ article about this (actually it was about the MS
ListView control) by Matt Hart, but I've misplaced my copy of it. It had
something to do with hooking WM_KILLFOCUS, EN_SETFOCUS, EN_UPDATE and other
such things... and his web site doesn't seem to have the article anymore.
Damit Senanayake | email@example.com | http://vulcan.spaceports.com/~damit/
Please reply to newsgroups, not by e-mail. | ICQ: 6930718
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center