Problem getting original edit commands while editing a CLi
Michael -- Michael.Dunphy@HBC.honeywell.com Wednesday, January 08, 1997 [Mini-digest: 2 responses] You could set a flag in your LVN_BEGINLABELEDIT handler and clear it in your LVN_ENDLABELEDIT handler. In your handlers for the ID_EDIT_ commands, execute code for the original behavior or your new behavior, depending on the value of the flag. > Environment: Win95, VC++ 4.2b > I have a view which is derived from CListView. I enable label editing. > My view has an ON_COMMAND for ID_EDIT_CLEAR. > When editing a label, when the user presses the DEL key (which is an > accelerator for ID_EDIT_CLEAR), instead of erasing the selected portion > of the label (which is the original command handler), my OnEditClear is > called. > Before connecting ID_EDIT_CLEAR to my own command, it worked OK - > just like it works in the explorer, for example. > The same problem happens with other ID_EDIT_ commands. > If I disable ID_EDIT_CLEAR (in the ON_UPDATE_COMMAND_UI) when > editing a label, then nothing happens when the user presses DEL. > My question is, how can I tell the list view that when editing, call the > original edit commands (I know when I'm editing a label). -----From: Amir Shoval>---------- >From: Dunphy, Michael[SMTP:Michael.Dunphy@HBC.honeywell.com] >Sent: =E9=E5=ED =E7=EE=E9=F9=E9 09 =E9=F0=E5=E0=F8 1997 01:59 >To: mfc-l@netcom.com >Cc: Amir Shoval >Subject: Re: Problem getting original edit commands while editing a = CLi >stView's label > >You could set a flag in your LVN_BEGINLABELEDIT handler and >clear it in your LVN_ENDLABELEDIT handler. In your handlers for >the ID_EDIT_ commands, execute code for the original behavior >or your new behavior, depending on the value of the flag. > >How exactly can I execute the code for the original behavior?=20 >As I said, I already know when I'm in edit mode. What I'm missing is, = how >to alter the ID_EDIT_ commands. > >TIA > Amir ----------------------------------------------- Amir Shoval N.C.C. Israel amirs@ncc.co.il ----------------------------------------------- >> Environment: Win95, VC++ 4.2b >> I have a view which is derived from CListView. I enable label = editing. >> My view has an ON_COMMAND for ID_EDIT_CLEAR. >> When editing a label, when the user presses the DEL key (which is an >> accelerator for ID_EDIT_CLEAR), instead of erasing the selected = portion >> of the label (which is the original command handler), my OnEditClear = is >> called. >> Before connecting ID_EDIT_CLEAR to my own command, it worked OK - >> just like it works in the explorer, for example. >> The same problem happens with other ID_EDIT_ commands. >> If I disable ID_EDIT_CLEAR (in the ON_UPDATE_COMMAND_UI) when >> editing a label, then nothing happens when the user presses DEL. >> My question is, how can I tell the list view that when editing, call = =20 >the >> original edit commands (I know when I'm editing a label). > >
Michael -- Michael.Dunphy@HBC.honeywell.com Sunday, January 12, 1997 > >You could set a flag in your LVN_BEGINLABELEDIT handler and > >clear it in your LVN_ENDLABELEDIT handler. In your handlers for > >the ID_EDIT_ commands, execute code for the original behavior > >or your new behavior, depending on the value of the flag. >How exactly can I execute the code for the original behavior? >As I said, I already know when I'm in edit mode. What I'm missing is, >how to alter the ID_EDIT_ commands. For your cut/copy/paste/undo handlers: void CDemoView::OnEditCopy() { if (m_bEditingLabel) { CEdit* pLabelEdit = GetListCtrl().GetEditControl(); if (pLabelEdit != NULL); pLabelEdit->Copy(); } else { // Your new code } } For your ID_EDIT_CLEAR handler: void CDemoView::OnEditDelete() { if (m_bEditingLabel) { CEdit* pLabelEdit = GetListCtrl().GetEditControl(); if (pLabelEdit == NULL) return; int nStartChar, nEndChar; pLabelEdit->GetSel(nStartChar, nEndChar); if (nEndChar <= nStartChar) // if no characters are selected { // delete first character after cursor nEndChar = nStartChar + 1; pLabelEdit->SetSel(nStartChar, nEndChar, TRUE); } pLabelEdit->ReplaceSel(_T("")); } else { // Your new code } } I know this extra coding is not the implementation you were looking for; but I hope it meets your needs. Cheers, Mike Dunphy
| Вернуться в корень Архива |