--- np2/win9xc/trace.cpp 2003/11/14 07:37:29 1.3 +++ np2/win9xc/trace.cpp 2004/02/12 17:18:16 1.7 @@ -38,7 +38,8 @@ extern HINSTANCE hPrev; enum { IDM_TRACEEN = 3300, - IDM_TRACEFH + IDM_TRACEFH, + IDM_TRACECL }; static const char ProgTitle[] = "console"; @@ -46,6 +47,8 @@ static const char ClassName[] = "TRACE-c static const char ClassEdit[] = "EDIT"; static const char traceen[] = "Enable"; static const char tracefh[] = "File out"; +static const char tracecl[] = "Clear"; +static const char crlf[] = "\r\n"; static TRACEWIN tracewin; static HWND hView = NULL; @@ -71,6 +74,12 @@ static void View_ScrollToBottom(HWND hWn PostMessage(hWnd, EM_LINESCROLL, 0, MaxPos); } +static void View_ClrString(void) { + + szView[0] = '\0'; + SetWindowText(hView, szView); +} + static void View_AddString(const char *lpszString) { int len, vlen; @@ -92,7 +101,7 @@ static void View_AddString(const char *l strcpy(szView, p); } strcat(szView, lpszString); - strcat(szView, str_crlf); + strcat(szView, crlf); SetWindowText(hView, szView); View_ScrollToBottom(hView); } @@ -109,7 +118,9 @@ static LRESULT CALLBACK traceproc(HWND h IDM_TRACEEN, traceen); InsertMenu(hmenu, 1, MF_BYPOSITION | MF_STRING, IDM_TRACEFH, tracefh); - InsertMenu(hmenu, 2, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); + InsertMenu(hmenu, 2, MF_BYPOSITION | MF_STRING, + IDM_TRACECL, tracecl); + InsertMenu(hmenu, 3, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); CheckMenuItem(hmenu, IDM_TRACEEN, (tracewin.en & 1)?MF_CHECKED:MF_UNCHECKED); @@ -161,6 +172,10 @@ static LRESULT CALLBACK traceproc(HWND h MF_CHECKED:MF_UNCHECKED); break; + case IDM_TRACECL: + View_ClrString(); + break; + default: return(DefWindowProc(hWnd, msg, wp, lp)); } @@ -249,8 +264,13 @@ void trace_init(void) { } } - tracewin.en = 1; +#if 1 + tracewin.en = 0; tracewin.fh = FILEH_INVALID; +#else + tracewin.en = 0; + tracewin.fh = file_create_c("out.txt"); +#endif tracecfg.posx = CW_USEDEFAULT; tracecfg.posy = CW_USEDEFAULT; @@ -301,7 +321,7 @@ void trace_fmt(const char *fmt, ...) { } if (tracewin.fh != FILEH_INVALID) { file_write(tracewin.fh, buf, strlen(buf)); - file_write(tracewin.fh, str_crlf, strlen(str_crlf)); + file_write(tracewin.fh, crlf, strlen(crlf)); } } }