Clinton Portis 211 Practically a Posting Shark

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:

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]));
     EndPaint(hwnd, &ps);

And here is the complete code thus far if needed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.