所以这是我的问题,它可以正常工作,直到达到一定数量的数据。我无法显示整个html文件,例如在它被切断的窗口中大约1MB。
窗口:
case WM_CREATE:
hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "",
WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_READONLY | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL,
0, 0, 100, 100, hWnd, (HMENU)IDC_MAIN_EDIT, GetModuleHandle(NULL), NULL);
if(hEdit == NULL)
MessageBox(hWnd, "Could not create edit box.", "Error", MB_OK | MB_ICONERROR);
hfDefault = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
LogText(hEdit,logstring);
break;
功能:
void LogText(HWND hEdit, const char * logstring)
{
const char * logstring2="\r\n";
int iLength = GetWindowTextLength(hEdit);
SendMessage(hEdit, EM_SETSEL, iLength, iLength);
SendMessage(hEdit, EM_REPLACESEL, 0, (LPARAM) logstring);
SendMessage(hEdit, WM_VSCROLL, SB_BOTTOM, (LPARAM)NULL);
int iLength2 = GetWindowTextLength(hEdit);
SendMessage(hEdit, EM_SETSEL, iLength2, iLength2);
SendMessage(hEdit, EM_REPLACESEL, 0, (LPARAM) logstring2);
SendMessage(hEdit, WM_VSCROLL, SB_BOTTOM, (LPARAM)NULL);
}
用法:
logstring="Test";
LogText(hEdit, logstring);
就像我说的那样,它工作得很完美,除了它在吐出未知数据后停止工作,我注意到这是一个非常一致的数字。