Thread: Multiline Edit Box Parser

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903

    Multiline Edit Box Parser

    Trying my hand at extracting user entered data from a multiline edit box... my strategy is to first, get the number of total lines from the edit box.. and the length of each line from the edit box.. and create a dynamic 2D array that is NULL terminated at the second dimension.. then read in the edit box line at a time..

    Came up with a little TextOut( ) loop just as a method to visually verify if my 2d array was loaded correctly.. and made a WM_COMMAND case to respond to the, "Add Count" pushbutton and call the EditBoxFileParser( ) function... which should load and display the contents of the Lines[][] 2d array.

    Please take a look when ye' get a chance.. at runtime, the user should be able to enter stuff in the edit box.. then click the, "Add Count" pushbutton.. and a display of the edit box conents should appear somewhere off to the right side of the screen..

    At this point, nothing happens when I enter stuff in the edit box and click the "add count" button..


    Here is my editbox file parser function:
    Code:
    void EditBoxFileParser(HWND hwnd, HWND hEdit)
    {
         
         int iCount, iLength;
         TCHAR **Lines;
         
         //Get Number of Lines in Edit Field
         iCount = SendMessage(hEdit, EM_GETLINECOUNT, 0, 0);
         
         Lines = new TCHAR*[iCount];
         
         //Populate 2D array - Lines[LineIndex][LineText]
         for(int i=0; i<iCount; i++)
         {     
              iLength = SendMessage(hEdit, EM_LINELENGTH, i, 0);
              Lines[i] = new TCHAR[iLength+1];
              SendMessage(hEdit, EM_GETLINE, i, (LPARAM)Lines[i]);
              Lines[i][iLength+1] = '\0';
         }
         
    
         //Visually verify the Lines[][] 2D array
         HDC hdc;
         PAINTSTRUCT ps;          
         HFONT hFont;
         
         hdc = BeginPaint(hwnd, &ps);
         hFont = (HFONT)GetStockObject(SYSTEM_FONT);
         SelectObject(hdc, hFont);
         
         for(int i=0, x=200, y=200; i<iCount; i++)
              
                 TextOut(hdc, x, y+=10, Lines[i], lstrlen(Lines[i]));
                 
         DeleteObject(hFont);
         EndPaint(hwnd, &ps);
         
    }

    And here is the complete code thus far if needed.
    Last edited by The Brain; 10-30-2005 at 07:20 AM.
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  2. edit box
    By beene in forum Windows Programming
    Replies: 3
    Last Post: 11-11-2006, 04:40 AM
  3. How to program a "back" button with MFC
    By 99atlantic in forum Windows Programming
    Replies: 3
    Last Post: 04-26-2005, 08:34 PM
  4. display a file in dropdown edit box
    By sunburnbyRA in forum Windows Programming
    Replies: 2
    Last Post: 03-10-2004, 01:58 PM
  5. Edit box question
    By learning110 in forum Windows Programming
    Replies: 6
    Last Post: 03-28-2003, 08:16 PM