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. List Box & Rich Edit box [modified]

List Box & Rich Edit box [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
jsontutorialquestion
31 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.
  • P prasad_som

    Suresh H wrote:

    List box contains a list of file names , when we select any item in the list box that file contains should get added to rich edit box.

    You can handle list box double click in following way,

    case WM_COMMAND:
    switch(LOWORD(wParam))
    case IDC_LIST1:
    if (HIWORD(wParam) == LBN_DBLCLK)
    {
    //double clicked
    }
    break;

    Prasad Notifier using ATL | Operator new[],delete[][^]

    S Offline
    S Offline
    Suresh H
    wrote on last edited by
    #22

    Hi Prasad, Thank you very much list box double click event is work.:)

    P 1 Reply Last reply
    0
    • S Suresh H

      Hi Prasad, Thank you very much list box double click event is work.:)

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #23

      Welcome ! :)

      Prasad Notifier using ATL | Operator new[],delete[][^]

      S 1 Reply Last reply
      0
      • P prasad_som

        Welcome ! :)

        Prasad Notifier using ATL | Operator new[],delete[][^]

        S Offline
        S Offline
        Suresh H
        wrote on last edited by
        #24

        Hi Prasad, One more last problem. After the double click event I am trying to read the file contents and display the file connects in rich edit box for that I am trying this code but I am not getting any out put can u please check what changes I have to make. const N = 1000; char cont[N]; ifstream fin; fin.open(FName); while(fin) { fin.getline(cont,1000); ::SendMessage(hwndRichEdit,WM_SETTEXT, 0,(WPARAM)cont); } fin.close(); i have tryed this code in mfc this is working properly but this code does not work in win 32 api, CStdioFile file(str, CFile::modeRead); DWORD dwSize = file.GetLength(); char *pBuffer = new char[dwSize + 1]; UINT uRead = file.Read(pBuffer, dwSize); pBuffer[uRead] = '\0'; file.Close(); ::SendMessage(hwndRichEdit,WM_SETTEXT, 0,(WPARAM)pBuffer); delete [] pBuffer;

        P 1 Reply Last reply
        0
        • S Suresh H

          Hi Prasad, One more last problem. After the double click event I am trying to read the file contents and display the file connects in rich edit box for that I am trying this code but I am not getting any out put can u please check what changes I have to make. const N = 1000; char cont[N]; ifstream fin; fin.open(FName); while(fin) { fin.getline(cont,1000); ::SendMessage(hwndRichEdit,WM_SETTEXT, 0,(WPARAM)cont); } fin.close(); i have tryed this code in mfc this is working properly but this code does not work in win 32 api, CStdioFile file(str, CFile::modeRead); DWORD dwSize = file.GetLength(); char *pBuffer = new char[dwSize + 1]; UINT uRead = file.Read(pBuffer, dwSize); pBuffer[uRead] = '\0'; file.Close(); ::SendMessage(hwndRichEdit,WM_SETTEXT, 0,(WPARAM)pBuffer); delete [] pBuffer;

          P Offline
          P Offline
          prasad_som
          wrote on last edited by
          #25

          Suresh H wrote:

          const N = 1000; char cont[N]; ifstream fin; fin.open(FName); while(fin) { fin.getline(cont,1000); ::SendMessage(hwndRichEdit,WM_SETTEXT, 0,(WPARAM)cont); } fin.close();

          Here, are you succesfully able to open the file ? Initialize char array like this,

          char cont[N] = { '\0'};

          Prasad Notifier using ATL | Operator new[],delete[][^]

          S 1 Reply Last reply
          0
          • P prasad_som

            Suresh H wrote:

            const N = 1000; char cont[N]; ifstream fin; fin.open(FName); while(fin) { fin.getline(cont,1000); ::SendMessage(hwndRichEdit,WM_SETTEXT, 0,(WPARAM)cont); } fin.close();

            Here, are you succesfully able to open the file ? Initialize char array like this,

            char cont[N] = { '\0'};

            Prasad Notifier using ATL | Operator new[],delete[][^]

            S Offline
            S Offline
            Suresh H
            wrote on last edited by
            #26

            Hi Prasad, I just did that changes but no output. I traced the statements, it open the file and it reads till end of the file, Since its in the loop the cont value keeps on changing ….and also nothing is added to the rich edit box. Is there any way where I can open the file read the complete contents of the file and store it in one variable and pass that variable to get displayed in the rich edit ??? Files which I am trying to open are simple text files which contains lots of blank lines in the starting and end of the file .

            P 1 Reply Last reply
            0
            • S Suresh H

              Hi Prasad, I just did that changes but no output. I traced the statements, it open the file and it reads till end of the file, Since its in the loop the cont value keeps on changing ….and also nothing is added to the rich edit box. Is there any way where I can open the file read the complete contents of the file and store it in one variable and pass that variable to get displayed in the rich edit ??? Files which I am trying to open are simple text files which contains lots of blank lines in the starting and end of the file .

              P Offline
              P Offline
              prasad_som
              wrote on last edited by
              #27

              I dont see any problem there, as long as array has some value.

              Prasad Notifier using ATL | Operator new[],delete[][^]

              S 1 Reply Last reply
              0
              • P prasad_som

                I dont see any problem there, as long as array has some value.

                Prasad Notifier using ATL | Operator new[],delete[][^]

                S Offline
                S Offline
                Suresh H
                wrote on last edited by
                #28

                Prasad I think since we are using WM_SETTEXT its replacing the rich edit contents ?? can we use some message where it adds to rich edit box with out replacing the old contents ??

                P 1 Reply Last reply
                0
                • S Suresh H

                  Prasad I think since we are using WM_SETTEXT its replacing the rich edit contents ?? can we use some message where it adds to rich edit box with out replacing the old contents ??

                  P Offline
                  P Offline
                  prasad_som
                  wrote on last edited by
                  #29

                  There is message EM_SETTEXTEX. But instead, read whole file content in to string, and use WM_SETTEXT.

                  Prasad Notifier using ATL | Operator new[],delete[][^]

                  S 1 Reply Last reply
                  0
                  • P prasad_som

                    There is message EM_SETTEXTEX. But instead, read whole file content in to string, and use WM_SETTEXT.

                    Prasad Notifier using ATL | Operator new[],delete[][^]

                    S Offline
                    S Offline
                    Suresh H
                    wrote on last edited by
                    #30

                    Hi prasad, How to read the whole file content in to string at a time ::???

                    P 1 Reply Last reply
                    0
                    • S Suresh H

                      Hi prasad, How to read the whole file content in to string at a time ::???

                      P Offline
                      P Offline
                      prasad_som
                      wrote on last edited by
                      #31

                      Loop though for reading for a fixed length, as you are doing now, and keep appending that array in a std::string variable.

                      Prasad Notifier using ATL | Operator new[],delete[][^]

                      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