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. Default edit/richeditctrl text selection allows easy delete after tab key to control.

Default edit/richeditctrl text selection allows easy delete after tab key to control.

Scheduled Pinned Locked Moved C / C++ / MFC
c++debugginghelpquestionannouncement
9 Posts 3 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.
  • L Offline
    L Offline
    lctrncs
    wrote on last edited by
    #1

    Greetings brilliant kind and helpful Code Project types! we the lurkers and lowly rabble thank you! i am using a dialog box as a front end to a flat file databaseon top of a document view SDI in the dialog, the user adds data to two edit controls (one rich edit - the other just an edit control) when the user tabs to either edit control, existing text in the control is selected, and if they begin text entry without clearing the slection, the existing text is deleted the NO Hide Selection check box in the resources editor only clears the selection when the control loses focus using EN_SETFOCUS (after changing the on_notify to on_en_setfocus in the message map), a pointer to the control and SelSel(0,0) *Works Great In Debug Configuration*, HOWEVER the RELEASE configuration gives an Access Violatin exception, even without my pointer and SetSel(0,0), whenever you call oninitdialog when the onsetfocus code is present the debugger provides error cxx0017 error: symbol "this" not found - and the code displayed is in \mfc\src\appmodul.cpp documented as "export winmain to force linkage to thes module" I hvae also tried using pointer/setsel in other locations without success Any Suggestions? how might I change my program so that it is harder for the user to delete existing text which has unwanted selection upon gaining focus to the edit control using the tab key? Thanks in advance for your time and consideration

    "For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash

    D J 2 Replies Last reply
    0
    • L lctrncs

      Greetings brilliant kind and helpful Code Project types! we the lurkers and lowly rabble thank you! i am using a dialog box as a front end to a flat file databaseon top of a document view SDI in the dialog, the user adds data to two edit controls (one rich edit - the other just an edit control) when the user tabs to either edit control, existing text in the control is selected, and if they begin text entry without clearing the slection, the existing text is deleted the NO Hide Selection check box in the resources editor only clears the selection when the control loses focus using EN_SETFOCUS (after changing the on_notify to on_en_setfocus in the message map), a pointer to the control and SelSel(0,0) *Works Great In Debug Configuration*, HOWEVER the RELEASE configuration gives an Access Violatin exception, even without my pointer and SetSel(0,0), whenever you call oninitdialog when the onsetfocus code is present the debugger provides error cxx0017 error: symbol "this" not found - and the code displayed is in \mfc\src\appmodul.cpp documented as "export winmain to force linkage to thes module" I hvae also tried using pointer/setsel in other locations without success Any Suggestions? how might I change my program so that it is harder for the user to delete existing text which has unwanted selection upon gaining focus to the edit control using the tab key? Thanks in advance for your time and consideration

      "For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash

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

      lctrncs wrote:

      how might I change my program so that it is harder for the user to delete existing text which has unwanted selection upon gaining focus to the edit control using the tab key?

      When the control receives focus, call its SetSel(0, 0) method.


      "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

      "Judge not by the eye but by the heart." - Native American Proverb

      1 Reply Last reply
      0
      • L lctrncs

        Greetings brilliant kind and helpful Code Project types! we the lurkers and lowly rabble thank you! i am using a dialog box as a front end to a flat file databaseon top of a document view SDI in the dialog, the user adds data to two edit controls (one rich edit - the other just an edit control) when the user tabs to either edit control, existing text in the control is selected, and if they begin text entry without clearing the slection, the existing text is deleted the NO Hide Selection check box in the resources editor only clears the selection when the control loses focus using EN_SETFOCUS (after changing the on_notify to on_en_setfocus in the message map), a pointer to the control and SelSel(0,0) *Works Great In Debug Configuration*, HOWEVER the RELEASE configuration gives an Access Violatin exception, even without my pointer and SetSel(0,0), whenever you call oninitdialog when the onsetfocus code is present the debugger provides error cxx0017 error: symbol "this" not found - and the code displayed is in \mfc\src\appmodul.cpp documented as "export winmain to force linkage to thes module" I hvae also tried using pointer/setsel in other locations without success Any Suggestions? how might I change my program so that it is harder for the user to delete existing text which has unwanted selection upon gaining focus to the edit control using the tab key? Thanks in advance for your time and consideration

        "For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash

        J Offline
        J Offline
        Justin Tay
        wrote on last edited by
        #3

        lctrncs wrote:

        when the user tabs to either edit control, existing text in the control is selected

        This is the default behaviour of the dialog manager. If this is undesirable you should tell the dialog manager, by subclassing the edit control and handling WM_GETDLGCODE[^] to not return the DLGC_HASSETSEL flag (call the base class procedure and mask it out ie. & ~DLGC_HASSETSEL).

        lctrncs wrote:

        using EN_SETFOCUS (after changing the on_notify to on_en_setfocus in the message map),

        How did you go about doing this? Using the IDE or manual edits to the message map? EN_SETFOCUS is sent through a WM_COMMAND message, and not a WM_NOTIFY message. The member function signature for both are different. Not sure if this is the problem though as I think the compiler should complain if you made a mistake. Edit: Link regarding WM_GETDLGCODE http://blogs.msdn.com/oldnewthing/archive/2003/11/14/55678.aspx[^] -- modified at 15:19 Thursday 24th August, 2006

        L 1 Reply Last reply
        0
        • J Justin Tay

          lctrncs wrote:

          when the user tabs to either edit control, existing text in the control is selected

          This is the default behaviour of the dialog manager. If this is undesirable you should tell the dialog manager, by subclassing the edit control and handling WM_GETDLGCODE[^] to not return the DLGC_HASSETSEL flag (call the base class procedure and mask it out ie. & ~DLGC_HASSETSEL).

          lctrncs wrote:

          using EN_SETFOCUS (after changing the on_notify to on_en_setfocus in the message map),

          How did you go about doing this? Using the IDE or manual edits to the message map? EN_SETFOCUS is sent through a WM_COMMAND message, and not a WM_NOTIFY message. The member function signature for both are different. Not sure if this is the problem though as I think the compiler should complain if you made a mistake. Edit: Link regarding WM_GETDLGCODE http://blogs.msdn.com/oldnewthing/archive/2003/11/14/55678.aspx[^] -- modified at 15:19 Thursday 24th August, 2006

          L Offline
          L Offline
          lctrncs
          wrote on last edited by
          #4

          hfry - thanx. your proposed solution looks feasible, and I will give it a try soon I will have to understand all this subclassing stuff first... it looks interesting. You asked about how I changed on_notify and on_en_setfocus

          hfry wrote:

          How did you go about doing this? Using the IDE or manual edits to the message map?

          I based my changes on this url http://support.microsoft.com/default.aspx?scid=kb;en-us;181664[^] after making the ON_NOTIFY TO EN_SETFOCUS change to the messagemap associated withthe Visual C++ 5.0 and 6.0 bug discussed in the link I added my pointer/SetSel(0,0) code to the OnSetFocusTheEditControl function there were no compiler errors everything worked fine in debug configuration however, changing to release configuration caused an access violation - with or without my pointer/SetSel(0,0) code whenever the modified function was present the Microsoft page about the bug also said that you had to have AfxInitRichedit() in your dialog initinstance and modify the message handlers, but I cannot find any difference in the handlers other than the arguments variations on these themes were not successful either - still the Access Violation in release config when oninit the dialog A different link suggested that my pointer might be trying to hit the control before it existed - maybe that is the missing "this"? However, the problem occurs even without my pointer I tried to use the en_killfocus a while back for something else using the same type of messagemap modifications, and had a similar release configuration exception - which forced me to use a different aproach I wish I understood what the problem is with the modified on_en_setfocus, or better, how to eliminate it in release config and understand it. I hope this answers your question. Thanks again.

          "For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash

          J 1 Reply Last reply
          0
          • L lctrncs

            hfry - thanx. your proposed solution looks feasible, and I will give it a try soon I will have to understand all this subclassing stuff first... it looks interesting. You asked about how I changed on_notify and on_en_setfocus

            hfry wrote:

            How did you go about doing this? Using the IDE or manual edits to the message map?

            I based my changes on this url http://support.microsoft.com/default.aspx?scid=kb;en-us;181664[^] after making the ON_NOTIFY TO EN_SETFOCUS change to the messagemap associated withthe Visual C++ 5.0 and 6.0 bug discussed in the link I added my pointer/SetSel(0,0) code to the OnSetFocusTheEditControl function there were no compiler errors everything worked fine in debug configuration however, changing to release configuration caused an access violation - with or without my pointer/SetSel(0,0) code whenever the modified function was present the Microsoft page about the bug also said that you had to have AfxInitRichedit() in your dialog initinstance and modify the message handlers, but I cannot find any difference in the handlers other than the arguments variations on these themes were not successful either - still the Access Violation in release config when oninit the dialog A different link suggested that my pointer might be trying to hit the control before it existed - maybe that is the missing "this"? However, the problem occurs even without my pointer I tried to use the en_killfocus a while back for something else using the same type of messagemap modifications, and had a similar release configuration exception - which forced me to use a different aproach I wish I understood what the problem is with the modified on_en_setfocus, or better, how to eliminate it in release config and understand it. I hope this answers your question. Thanks again.

            "For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash

            J Offline
            J Offline
            Justin Tay
            wrote on last edited by
            #5

            The handler should look like void OnSetfocusRichedit1(); instead of void OnSetfocusRichedit1(NMHDR* pNMHDR, LRESULT* pResult); Is the first handler what you have?

            L 1 Reply Last reply
            0
            • J Justin Tay

              The handler should look like void OnSetfocusRichedit1(); instead of void OnSetfocusRichedit1(NMHDR* pNMHDR, LRESULT* pResult); Is the first handler what you have?

              L Offline
              L Offline
              lctrncs
              wrote on last edited by
              #6

              I tried both - but I got compiler errors unless I included the LRESULT*pResult argument for the first one.

              "For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash

              J 1 Reply Last reply
              0
              • L lctrncs

                I tried both - but I got compiler errors unless I included the LRESULT*pResult argument for the first one.

                "For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash

                J Offline
                J Offline
                Justin Tay
                wrote on last edited by
                #7

                lctrncs wrote:

                I got compiler errors unless I included the LRESULT*pResult argument for the first one.

                That can't be right. What are the compile errors? Having a return value when there isn't supposed to be one would put your stack out of whack. I don't have VC6 (I use VS2003) so the classwizard is fine. I created a simple MFC dialog app, added a Edit and RichEdit control and have focus handlers for both and I can't duplicate this behaviour.

                L 1 Reply Last reply
                0
                • J Justin Tay

                  lctrncs wrote:

                  I got compiler errors unless I included the LRESULT*pResult argument for the first one.

                  That can't be right. What are the compile errors? Having a return value when there isn't supposed to be one would put your stack out of whack. I don't have VC6 (I use VS2003) so the classwizard is fine. I created a simple MFC dialog app, added a Edit and RichEdit control and have focus handlers for both and I can't duplicate this behaviour.

                  L Offline
                  L Offline
                  lctrncs
                  wrote on last edited by
                  #8

                  Wow. Thanks for your feedback! I very much appreciate it. You seem interested in this from an almost didactic standpoint. I can appreciate that. I need to clear the selection on my control so my users do not erase their data. Perhaps we can collaborate. What can't be right? Including the LRESULT*pResult? Let me first say that I used to test ATM network protocol analyzers for HP - and can test many options quickly. Let me know more about your area of interest - and I will try to assist. Lets review the possibilities. I am using Visual C++ 6.0 Standard (copyright 1994-1998) MSCorp. I used the classwizard to add an EN_SETFOCUS function for either/both a rich edit control or an edit control, then changed the message map as directed by the microsoft bug admission url (see previous message) - and added AfxInitRichEdit(); to my InitInsatnce as directed by the MS URL. Perhaps this is/can be a baseline? I will test the options now - good thing I am sleep apnea/narcoletpic/insomniac! 1. does afxinitrichedit end exception if present in initinstance if altered on_en_setfocus code present(not include SetSel) in release? stand by ... release config - no onsetfocus -> no access violotion - open dilog box interface to DB on top of document view - no problem remove comments from altered on_notify->on_en_setfocus map/handler/function - but no pointer/SetSel(0,0) code int onsetfocus function... PS: dialog box modeless.... ->Unhandled exceptoin - access violation = true. onsetfocus arguments (Lresult *pResult) -> onsetfocus arguments (Lresult *pResult) ->access violation = true onsetfocus arguments () -> access violation = true onsetfocus arguments (NMHDR, pNMHDR, Lresult *pResult) -> access violation = true ADD SetSel(0,0) -> access violation = true previous post appears incorrect that onsetfocus arguments (Lresult *pResult) ->access violation = false <- false if setfocus code present - even though compiles in debug p (after) changing on_notify to ON-En-Setfocus - access violation in release config no possibility appears to function when unaltered, or altered onsetfocus code present in release config (although fixed in debug when onsetfocus arguments (NMHDR, pNMHDR, Lresult *pResult). A local high end embedded programmer suggested that I might not have allthe libraries I need. perhaps I should be trying to learn about subclassing All I want to do is clear a selection when I hit the control... WHY is this

                  L 1 Reply Last reply
                  0
                  • L lctrncs

                    Wow. Thanks for your feedback! I very much appreciate it. You seem interested in this from an almost didactic standpoint. I can appreciate that. I need to clear the selection on my control so my users do not erase their data. Perhaps we can collaborate. What can't be right? Including the LRESULT*pResult? Let me first say that I used to test ATM network protocol analyzers for HP - and can test many options quickly. Let me know more about your area of interest - and I will try to assist. Lets review the possibilities. I am using Visual C++ 6.0 Standard (copyright 1994-1998) MSCorp. I used the classwizard to add an EN_SETFOCUS function for either/both a rich edit control or an edit control, then changed the message map as directed by the microsoft bug admission url (see previous message) - and added AfxInitRichEdit(); to my InitInsatnce as directed by the MS URL. Perhaps this is/can be a baseline? I will test the options now - good thing I am sleep apnea/narcoletpic/insomniac! 1. does afxinitrichedit end exception if present in initinstance if altered on_en_setfocus code present(not include SetSel) in release? stand by ... release config - no onsetfocus -> no access violotion - open dilog box interface to DB on top of document view - no problem remove comments from altered on_notify->on_en_setfocus map/handler/function - but no pointer/SetSel(0,0) code int onsetfocus function... PS: dialog box modeless.... ->Unhandled exceptoin - access violation = true. onsetfocus arguments (Lresult *pResult) -> onsetfocus arguments (Lresult *pResult) ->access violation = true onsetfocus arguments () -> access violation = true onsetfocus arguments (NMHDR, pNMHDR, Lresult *pResult) -> access violation = true ADD SetSel(0,0) -> access violation = true previous post appears incorrect that onsetfocus arguments (Lresult *pResult) ->access violation = false <- false if setfocus code present - even though compiles in debug p (after) changing on_notify to ON-En-Setfocus - access violation in release config no possibility appears to function when unaltered, or altered onsetfocus code present in release config (although fixed in debug when onsetfocus arguments (NMHDR, pNMHDR, Lresult *pResult). A local high end embedded programmer suggested that I might not have allthe libraries I need. perhaps I should be trying to learn about subclassing All I want to do is clear a selection when I hit the control... WHY is this

                    L Offline
                    L Offline
                    lctrncs
                    wrote on last edited by
                    #9

                    After 10 winks or so, I thought I would run through the cases again to make sure I didn't miss anything. This time, it appears to work in release config with the following changes to the original code ... AfxInitRichEdit in the initinstance alterations to the classwizard's incorrect messagemap from on_notify to on_en_setfocus alterations to the handler to reflect change in messagemap including removing all arguments in the handler - and then the function maybe the key ingredient here was sleep! I think I go get more. Thanks for your help!

                    "For a successful technology, reality must take precedence over public relations, for nature cannot be fooled." Richard Feynman, Minority Report to the Official Report on the Space Shuttle Challenger Crash

                    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