Problem with 'Delete' key.
-
Hi All, I am developing a 'Text editor' kind of application. I have derived a class from 'CView' and i am doing all text editor relevant operations with this. If i select some text and if i press 'Delete' button then my tool is deleting the selected text. But if i do the same thing without selecting the text then it is not deleting the characters. :doh: That means without selecting some text delete operation is not working... :(( Can any one please tell me how can i handle this ??? :zzz: Thanks & Regards Sanjeeva Kumar :rose:
-
Hi All, I am developing a 'Text editor' kind of application. I have derived a class from 'CView' and i am doing all text editor relevant operations with this. If i select some text and if i press 'Delete' button then my tool is deleting the selected text. But if i do the same thing without selecting the text then it is not deleting the characters. :doh: That means without selecting some text delete operation is not working... :(( Can any one please tell me how can i handle this ??? :zzz: Thanks & Regards Sanjeeva Kumar :rose:
-
But if i do the same thing without selecting the text then it is not deleting the characters.
Can you tell me is the cursor is focused in edit box when you are deleting the text in edit box. -
Hi Shashi, Yes. cursor is focused in test editor. I think i have not written code for handling the delete key event. Please tell me if you know how to handle this ??? Thanks in advance Sanjeeva Kumar.
Sanjeeva Kumar K wrote:
I think i have not written code for handling the delete key event.
But did you not earlier state that, "If i select some text and if i press 'Delete' button then my tool is deleting the selected text."? In your deletion code, are you first checking to see if any text is selected?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Sanjeeva Kumar K wrote:
I think i have not written code for handling the delete key event.
But did you not earlier state that, "If i select some text and if i press 'Delete' button then my tool is deleting the selected text."? In your deletion code, are you first checking to see if any text is selected?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Hi All, I am developing a 'Text editor' kind of application. I have derived a class from 'CView' and i am doing all text editor relevant operations with this. If i select some text and if i press 'Delete' button then my tool is deleting the selected text. But if i do the same thing without selecting the text then it is not deleting the characters. :doh: That means without selecting some text delete operation is not working... :(( Can any one please tell me how can i handle this ??? :zzz: Thanks & Regards Sanjeeva Kumar :rose:
I think u don't need to override the WM_KEYDOWN message. it will all happen automatically. or if u need to override for some reason then call base implementation in overridden function eg: If you are using the CEdit then you need to call the CEdit::OnKeyDown in ON_WM_KEYDOWN Message Handler function. Or if you are using a Win32 then u need call the Old Window procedure in your own window proc. i mean leave the deleting to the default message handler. that's it. BEGIN_MESSAGE_MAP(CMyEdit, CEdit) ON_WM_KEYDOWN(OnMyEditeyDown) END_MESSAGE_MAP() void CMyEdit::OnMyEditeyDown( UINT nChar, UINT nRepCnt, UINT nFlags ) { CEdit::OnKeyDown(nChar,nRepCnt,nFlags); // to Do } i think this will help you
-
I have written code for deleting characters only if some text is selected. If i simply press the 'Delete' button then this function is not invoked. do i need to handle it separately ??? Regards, Sanjeeva Kumar.
Sanjeeva Kumar K wrote:
do i need to handle it separately ???
I would think so.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
I think u don't need to override the WM_KEYDOWN message. it will all happen automatically. or if u need to override for some reason then call base implementation in overridden function eg: If you are using the CEdit then you need to call the CEdit::OnKeyDown in ON_WM_KEYDOWN Message Handler function. Or if you are using a Win32 then u need call the Old Window procedure in your own window proc. i mean leave the deleting to the default message handler. that's it. BEGIN_MESSAGE_MAP(CMyEdit, CEdit) ON_WM_KEYDOWN(OnMyEditeyDown) END_MESSAGE_MAP() void CMyEdit::OnMyEditeyDown( UINT nChar, UINT nRepCnt, UINT nFlags ) { CEdit::OnKeyDown(nChar,nRepCnt,nFlags); // to Do } i think this will help you