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. Highlight the words

Highlight the words

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
9 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.
  • V Offline
    V Offline
    VinayCool
    wrote on last edited by
    #1

    Hi, I have dialog window in which I have a list box which contains file name as items, all these files are text files which open by default by note pad. Along with the file name I have some offsets (location of some words in the text file), till now I have finished just opening a file I want to know is there anyway in VC++ that we can open the file and highlight those words after file opening? I want to highlight the words in notepad or I can create a new dialog where I can display the contents of the file and highlight the words …can u please give me some information how to proceed with this work … Regards, Vinay Charan.

    H Steve EcholsS 2 Replies Last reply
    0
    • V VinayCool

      Hi, I have dialog window in which I have a list box which contains file name as items, all these files are text files which open by default by note pad. Along with the file name I have some offsets (location of some words in the text file), till now I have finished just opening a file I want to know is there anyway in VC++ that we can open the file and highlight those words after file opening? I want to highlight the words in notepad or I can create a new dialog where I can display the contents of the file and highlight the words …can u please give me some information how to proceed with this work … Regards, Vinay Charan.

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      I think you want to search in file_**


      **_

      whitesky


      H V 2 Replies Last reply
      0
      • H Hamid Taebi

        I think you want to search in file_**


        **_

        whitesky


        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #3

        if yes see ScanR - Text file string search and replace engine [^]_**


        **_

        whitesky


        1 Reply Last reply
        0
        • H Hamid Taebi

          I think you want to search in file_**


          **_

          whitesky


          V Offline
          V Offline
          VinayCool
          wrote on last edited by
          #4

          Hi WhiteSky, Thanks for the reply.... I dont want to search in the file.. I just want to Highlight the words which are present along with the file name Data which i have is filename & offsets (200,340,450,700 location of the words) now i have open the file and i have to Highlight the words its there any way i can complete this task in VC++ ??

          L 1 Reply Last reply
          0
          • V VinayCool

            Hi, I have dialog window in which I have a list box which contains file name as items, all these files are text files which open by default by note pad. Along with the file name I have some offsets (location of some words in the text file), till now I have finished just opening a file I want to know is there anyway in VC++ that we can open the file and highlight those words after file opening? I want to highlight the words in notepad or I can create a new dialog where I can display the contents of the file and highlight the words …can u please give me some information how to proceed with this work … Regards, Vinay Charan.

            Steve EcholsS Offline
            Steve EcholsS Offline
            Steve Echols
            wrote on last edited by
            #5

            You could probably read the file into CRichEditCtrl, loop through each of your words and highlight them (make them bold, change the color, etc.) using the SetSel and SetSelectionCharFormat functions. I don't have an example, just an idea you might be able to look into....


            - S 50 cups of coffee and you know it's on!

            • S
              50 cups of coffee and you know it's on!
              Code, follow, or get out of the way.
            1 Reply Last reply
            0
            • V VinayCool

              Hi WhiteSky, Thanks for the reply.... I dont want to search in the file.. I just want to Highlight the words which are present along with the file name Data which i have is filename & offsets (200,340,450,700 location of the words) now i have open the file and i have to Highlight the words its there any way i can complete this task in VC++ ??

              L Offline
              L Offline
              Laxman Auti
              wrote on last edited by
              #6

              Vinay wrote:

              I just want to Highlight the words which are present along with the file name Data which i have is filename & offsets (200,340,450,700 location of the words) now i have open the file and i have to Highlight the words its there any way i can complete this task in VC++ ??

              You may required hooking of the NOTEPAD.exe Application so that you can explicitly highlight the words from other application. Because you are using ShellExecute() for opening files where you never get the Handle of the opened file. Other way is to Use the RichEditCtrl and open the file using CFile or CStdioFile and put the contents into that RichEditCtrl and do whatever you want, as it is in your application scope..:) Knock out 't' from can't, You can if you think you can :cool:

              V 2 Replies Last reply
              0
              • L Laxman Auti

                Vinay wrote:

                I just want to Highlight the words which are present along with the file name Data which i have is filename & offsets (200,340,450,700 location of the words) now i have open the file and i have to Highlight the words its there any way i can complete this task in VC++ ??

                You may required hooking of the NOTEPAD.exe Application so that you can explicitly highlight the words from other application. Because you are using ShellExecute() for opening files where you never get the Handle of the opened file. Other way is to Use the RichEditCtrl and open the file using CFile or CStdioFile and put the contents into that RichEditCtrl and do whatever you want, as it is in your application scope..:) Knock out 't' from can't, You can if you think you can :cool:

                V Offline
                V Offline
                VinayCool
                wrote on last edited by
                #7

                Hi Laxman, When i add Rich Edit control i am getting run time error (VC++ Debug Library error) can u please tell what will the cause ...

                L 1 Reply Last reply
                0
                • V VinayCool

                  Hi Laxman, When i add Rich Edit control i am getting run time error (VC++ Debug Library error) can u please tell what will the cause ...

                  L Offline
                  L Offline
                  Laxman Auti
                  wrote on last edited by
                  #8

                  vinaycool wrote:

                  When i add Rich Edit control i am getting run time error (VC++ Debug Library error) can u please tell what will the cause ...

                  use following in InitInstance of the application AfxInitRichEdit (); Knock out 't' from can't, You can if you think you can :cool:

                  1 Reply Last reply
                  0
                  • L Laxman Auti

                    Vinay wrote:

                    I just want to Highlight the words which are present along with the file name Data which i have is filename & offsets (200,340,450,700 location of the words) now i have open the file and i have to Highlight the words its there any way i can complete this task in VC++ ??

                    You may required hooking of the NOTEPAD.exe Application so that you can explicitly highlight the words from other application. Because you are using ShellExecute() for opening files where you never get the Handle of the opened file. Other way is to Use the RichEditCtrl and open the file using CFile or CStdioFile and put the contents into that RichEditCtrl and do whatever you want, as it is in your application scope..:) Knock out 't' from can't, You can if you think you can :cool:

                    V Offline
                    V Offline
                    VinayCool
                    wrote on last edited by
                    #9

                    Hi Laxman, Now i have used CFile myFile("str", CFile::modeRead); how to pass the contents to Richedit box ?? I have created m_FCONT of type CRichEditCtrl .. I have no idea working with Rich Text

                    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