Matthew Wilson
Posted in reply to Stephen De Chellis
| Stephen, without looking in much detail in your code, I can tell you that EDIT controls have a weirdness with multi-line text.
It having been a while, I cannot recollect whether they must have \r\n for each line break, or \n, but my inclination is that it is the former.
Hope that helps. If not, put another post up, and I'll try and search my source database for something to inform us both
Matthew
"Stephen De Chellis" <steve@hmtk.com> wrote in message news:aseaic$fb4$1@digitaldaemon.com...
> I'm having problems displaying text in an edit control.
>
> Here is the code for the editor window:
>
> LRESULT CALLBACK EditWndProc (HWND hwnd, UINT message, WPARAM wParam,
LPARAM
> lParam)
> {
> static HWND hwndEdit, hwndButton;
> static HDC hdc;
> static int x=0, i=0;
> PAINTSTRUCT ps ;
> RECT rect ;
>
> switch (message)
> {
> case WM_CREATE:
> hwndButton=CreateWindow (TEXT ("button"), TEXT ("OK"), WS_CHILD |
> WS_VISIBLE,
> 5,560,100,30,
> hwnd, (HMENU) IDOK, ghInstance, NULL);
> hwndEdit=CreateWindow (TEXT ("edit"), szHistory, WS_CHILD | WS_VISIBLE |
> WS_BORDER | ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL,
> 5,5,700,550,
> hwnd, (HMENU) IDC_EDIT1, ghInstance, NULL);
> SetWindowText (hwndEdit, szHistory);
>
> return 0;
>
> case WM_PAINT :
> hdc = BeginPaint (hwnd, &ps) ;
>
> GetClientRect (hwnd, &rect);
>
> EndPaint (hwnd, &ps) ;
> return 0 ;
>
> case WM_COMMAND:
>
> switch (LOWORD (wParam))
> {
>
> case IDOK:
> // retrieve text
> GetWindowText (hwndEdit, szHistory, 32000) ;
> DestroyWindow(hwnd);
> }
> break ;
>
> }
> return DefWindowProc (hwnd, message, wParam, lParam) ;
> }
>
> I register the class:
>
> wndclass.style = CS_HREDRAW | CS_VREDRAW ;
> wndclass.lpfnWndProc = EditWndProc ;
> wndclass.cbClsExtra = 0 ;
> wndclass.cbWndExtra = 0 ;
> wndclass.hInstance = hInstance ;
> wndclass.hIcon = LoadIcon (hInstance, MAKEINTRESOURCE (IDI_ICON1)) ;
> wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
> wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
> wndclass.lpszMenuName = NULL ;
> wndclass.lpszClassName = TEXT ("EditWindow") ;
>
>
> Save:
>
> i=strlen(szHistory);
> fprintf(outfile,"%i ",i);
> fwrite(szHistory, i, 1, outfile);
>
> Load:
>
> fscanf(infile,"%i ",&i);
> fread(szHistory, sizelem, i, infile);
>
>
>
> After saving the text their is no problem, but after loading the saved
text
> back into the string all the <CR>'s are converted to vertical lines and
all
> the text is mashed together.
>
>
> --
> Thank You
> Stephen De Chellis
> steve@hmtk.com
>
> www.hmtk.com for HMTK information
> www.kenzerco.com for HackMaster information
>
>
> --
> Thank You
> Stephen De Chellis
> steve@hmtk.com
>
> www.hmtk.com for HMTK information
> www.kenzerco.com for HackMaster information
>
>
|