Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem with 'Delete' key.

Problem with 'Delete' key.

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sanjay K
    wrote on last edited by
    #1

    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:

    S N 2 Replies Last reply
    0
    • S Sanjay K

      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:

      S Offline
      S Offline
      sheshidar
      wrote on last edited by
      #2

      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.

      S 1 Reply Last reply
      0
      • S sheshidar

        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.

        S Offline
        S Offline
        Sanjay K
        wrote on last edited by
        #3

        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.

        D 1 Reply Last reply
        0
        • S Sanjay K

          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.

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          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

          S 1 Reply Last reply
          0
          • D David Crow

            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

            S Offline
            S Offline
            Sanjay K
            wrote on last edited by
            #5

            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.

            D 1 Reply Last reply
            0
            • S Sanjay K

              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:

              N Offline
              N Offline
              Nitheesh George
              wrote on last edited by
              #6

              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

              S 1 Reply Last reply
              0
              • S Sanjay K

                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.

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                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

                1 Reply Last reply
                0
                • N Nitheesh George

                  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

                  S Offline
                  S Offline
                  Sanjay K
                  wrote on last edited by
                  #8

                  Thanks Nitheesh. I will try this.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups