Re: Editing ListView Fields
- From: "James Brown" <not@xxxxxxxx>
- Date: Mon, 30 Oct 2006 07:50:07 -0000
"Jim W." <jw@xxxxxxxxxxxxx> wrote in message
news:IGd1h.3071$d95.2063@xxxxxxxxxxx
I'm using Orlando's free compiler programming in straight C.
What I would like to do is edit individual fields (subitems) in the
ListView.
I have been seaching the web for awhile and decided the way I would like
to start off simple as follows.
When a user right clicks on the field the program creates a child window
of the appropriate type to overlay the field.
For example if the field is a text field the program will create a child
EDIT window over the field.
What I have is a TabControl window which contains a Dialog which contains
a Listview
So far I have managed to
1. Capture the NM_RCLICK and create the EDIT window that overlays the
field and
2. set the focus to the Text window.
I can type into the text window but I cannot for the life of me figure out
how to end the edit in a reasonable way. I cannot figure out how to
capture the Enter key.
LVHITTESTINFO lvhiti;
<snip>
case NM_RCLICK:
<snip>
GetCursorPos(&lvhiti.pt);
ScreenToClient(hDlg, &lvhiti.pt);
i = SendMessage(hList,LVM_SUBITEMHITTEST,0,(LPARAM)&lvhiti);
ListView_GetSubItemRect(hList, ((int *)pNmHdr)[3],lvhiti.iSubItem ,
LVIR_BOUNDS, &crect);
hwnd1 = CreateWindow(__T("edit"),
"",
WS_CHILD|WS_VISIBLE|WS_BORDER,
crect.left, crect.top, crect.right-crect.left,
abs(crect.bottom-crect.top),
hList, // This is the HWND of the ListView
NULL,
hInst,
NULL);
SetFocus(hwnd1);
return FALSE;
Using hList as the parent I tried using NM_RETURN and the Enter key
doesn't show up there.
I've put a WM_KEYDOWN in the Dialog to no avail.
I've tried using the hDlg of the Dialog that contains the ListView as the
parent and still could not find the Enter when hit using the WM_KEYDOWN.
How do I capture the Enter key from a Child window within a ListView
within a Dialog?
Thanks,
JimW
The NM_RETURN notification is sent by common-controls, not by 'standard
controls' which is what the EDIT control is classified as. In addition, this
message is sent by the window that has focus, which is the EDIT control
itself. So you won't ever see that message.
You might want to subclass the edit-control and handle the WM_KEYDOWN
message, looking for the enter-key in there. Then post your own custom
message back to the parent when this happens. Make sure your edit-control
has the ES_WANTRETURN style set.
--
James Brown
Microsoft MVP - Windows SDK
www.catch22.net
Free Win32 Tutorials and Sourcecode
.
- Follow-Ups:
- Re: Editing ListView Fields
- From: Jim W.
- Re: Editing ListView Fields
- References:
- Editing ListView Fields
- From: Jim W.
- Editing ListView Fields
- Prev by Date: Re: TTM_Acitvate and Tooltips
- Next by Date: DialogBox and WM_SETICON
- Previous by thread: Editing ListView Fields
- Next by thread: Re: Editing ListView Fields
- Index(es):
Relevant Pages
|