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. CrichEditCtrl::Find returns zero when second RichEdit is Created as a Child of A Different CDialog

CrichEditCtrl::Find returns zero when second RichEdit is Created as a Child of A Different CDialog

Scheduled Pinned Locked Moved C / C++ / MFC
algorithmslearning
9 Posts 4 Posters 1 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.
  • F Offline
    F Offline
    ForNow
    wrote on last edited by
    #1

    Hi I have a CrichEditCtrl that works fine. However when the user Selects to view some other data in a Different Cdialog/CRichEditctrl. The first stops working and returns a zero I display the Text I am Searching for and the Returned code From FindText (in the caption bar) The Text looks fine However as soon as The Second Cdialog/RichEdit are created the return from the First CDaliog/RichEdit returns a zero I double checked things as resource id of both RicheditCtrl's and they are different

    L L 2 Replies Last reply
    0
    • F ForNow

      Hi I have a CrichEditCtrl that works fine. However when the user Selects to view some other data in a Different Cdialog/CRichEditctrl. The first stops working and returns a zero I display the Text I am Searching for and the Returned code From FindText (in the caption bar) The Text looks fine However as soon as The Second Cdialog/RichEdit are created the return from the First CDaliog/RichEdit returns a zero I double checked things as resource id of both RicheditCtrl's and they are different

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Are you saying both dialogs are open at the same time?

      F 1 Reply Last reply
      0
      • L Lost User

        Are you saying both dialogs are open at the same time?

        F Offline
        F Offline
        ForNow
        wrote on last edited by
        #3

        Yes Actually this is the 3rd CDialog/CRicheditCtrl Pair That I have in my application The parent window is the First Cdialog/CrichEditCtrl. However After this is Created the Find functionality of the Richedit which is a child control of my main (for lack of a better term)CDialog stops working

        L 1 Reply Last reply
        0
        • F ForNow

          Yes Actually this is the 3rd CDialog/CRicheditCtrl Pair That I have in my application The parent window is the First Cdialog/CrichEditCtrl. However After this is Created the Find functionality of the Richedit which is a child control of my main (for lack of a better term)CDialog stops working

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Without a lot more detail, including the code, it is anyone's guess. However using dialogs to open other dialogs does not sound like the best design.

          1 Reply Last reply
          0
          • F ForNow

            Hi I have a CrichEditCtrl that works fine. However when the user Selects to view some other data in a Different Cdialog/CRichEditctrl. The first stops working and returns a zero I display the Text I am Searching for and the Returned code From FindText (in the caption bar) The Text looks fine However as soon as The Second Cdialog/RichEdit are created the return from the First CDaliog/RichEdit returns a zero I double checked things as resource id of both RicheditCtrl's and they are different

            L Offline
            L Offline
            leon de boer
            wrote on last edited by
            #5

            If you can see the problem starts when it's returning zero then you have an obvious debug point. Place a debug point inside an if statement on the zero return ... when it breaks follow the steps backwards. The hard part is generally finding a debug point with this sort of problem but you have that already.

            In vino veritas

            F 1 Reply Last reply
            0
            • L leon de boer

              If you can see the problem starts when it's returning zero then you have an obvious debug point. Place a debug point inside an if statement on the zero return ... when it breaks follow the steps backwards. The hard part is generally finding a debug point with this sort of problem but you have that already.

              In vino veritas

              F Offline
              F Offline
              ForNow
              wrote on last edited by
              #6

              I added he following code want to see what is in the rich edit

              linechar = myedit->FindText(FR_DOWN , &listtext);
              if(linechar == 0)
              {

              CFile dumpfile;
              CFileException e;
              TCHAR\* pszFileName = \_T("F:\\\\DUMPLIST.LST");
              if(!dumpfile.Open(pszFileName, CFile::modeCreate | CFile::modeWrite, &e))
              	MessageBox("file could not be opened");
              EDITSTREAM dmp;
                 dmp.dwCookie = (DWORD\_PTR) &dumpfile;
                  dmp.pfnCallback = (EDITSTREAMCALLBACK)dumpit;
              	myedit->StreamOut(SF\_TEXT,dmp);
              

              }

              static DWORD CALLBACK dumpit(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
              {
              CFile* pFile = (CFile*) dwCookie;

              pFile->Write(pbBuff, cb);
              *pcb = cb;

              return 0;
              }

              F D 2 Replies Last reply
              0
              • F ForNow

                I added he following code want to see what is in the rich edit

                linechar = myedit->FindText(FR_DOWN , &listtext);
                if(linechar == 0)
                {

                CFile dumpfile;
                CFileException e;
                TCHAR\* pszFileName = \_T("F:\\\\DUMPLIST.LST");
                if(!dumpfile.Open(pszFileName, CFile::modeCreate | CFile::modeWrite, &e))
                	MessageBox("file could not be opened");
                EDITSTREAM dmp;
                   dmp.dwCookie = (DWORD\_PTR) &dumpfile;
                    dmp.pfnCallback = (EDITSTREAMCALLBACK)dumpit;
                	myedit->StreamOut(SF\_TEXT,dmp);
                

                }

                static DWORD CALLBACK dumpit(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
                {
                CFile* pFile = (CFile*) dwCookie;

                pFile->Write(pbBuff, cb);
                *pcb = cb;

                return 0;
                }

                F Offline
                F Offline
                ForNow
                wrote on last edited by
                #7

                thanks

                1 Reply Last reply
                0
                • F ForNow

                  I added he following code want to see what is in the rich edit

                  linechar = myedit->FindText(FR_DOWN , &listtext);
                  if(linechar == 0)
                  {

                  CFile dumpfile;
                  CFileException e;
                  TCHAR\* pszFileName = \_T("F:\\\\DUMPLIST.LST");
                  if(!dumpfile.Open(pszFileName, CFile::modeCreate | CFile::modeWrite, &e))
                  	MessageBox("file could not be opened");
                  EDITSTREAM dmp;
                     dmp.dwCookie = (DWORD\_PTR) &dumpfile;
                      dmp.pfnCallback = (EDITSTREAMCALLBACK)dumpit;
                  	myedit->StreamOut(SF\_TEXT,dmp);
                  

                  }

                  static DWORD CALLBACK dumpit(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
                  {
                  CFile* pFile = (CFile*) dwCookie;

                  pFile->Write(pbBuff, cb);
                  *pcb = cb;

                  return 0;
                  }

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

                  ForNow wrote:

                  I added he following code want to see what is in the rich edit

                  Why not just use:

                  CString str;
                  myedit->GetWindowText(str);

                  "One man's wage rise is another man's price increase." - Harold Wilson

                  "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                  "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

                  F 1 Reply Last reply
                  0
                  • D David Crow

                    ForNow wrote:

                    I added he following code want to see what is in the rich edit

                    Why not just use:

                    CString str;
                    myedit->GetWindowText(str);

                    "One man's wage rise is another man's price increase." - Harold Wilson

                    "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                    "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

                    F Offline
                    F Offline
                    ForNow
                    wrote on last edited by
                    #9

                    Would that code get what's in the rich edit good to know I did find the bug in my code What works in the debug version does not necessarily work in release by doing research the bugs have to do with the heap in my case I had forgotten to initialize CStatic *pointers after adding the '= new' code I resolved the problem thanks

                    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