|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++.windows.32-bits - Text problem
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
Dec 01 2002
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, Dec 01 2002
As far as I remember, in a multiline edit control, lines must be separated by "\r\r\n" (no typo, two \r and a \n). HTH, Laurentiu Stephen De Chellis wrote:I'm having problems displaying text in an edit control. Dec 02 2002
|