1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
char CommandConnected[] = "Command.User.Connected";
if(strncmp(CommandConnected, buffer, 22) == 0)
{
char Username[TEXT_SIZE];
using namespace std;
string str = string(buffer);
int stringL = strlen(buffer);
stringL = stringL - 23;
str.copy(Username, stringL, 23);
MessageBox(hWnd, Username, NULL, MB_OK);
sprintf(buffer, "%s%s", Username, " has connected to the server!\n");
HWND hwndOutput = GetDlgItem(hWnd, IDC_EDIT1);
int textLen = SendMessage(hwndOutput, WM_GETTEXTLENGTH, 0, 0);
SendMessage(hwndOutput, EM_SETSEL, textLen, textLen);
SendMessage(hwndOutput, EM_REPLACESEL, TRUE, (LPARAM)buffer);
SendMessage(hwndOutput, WM_VSCROLL, SB_BOTTOM, NULL);
}
else
{
HWND hwndOutput = GetDlgItem(hWnd, IDC_EDIT1);
int textLen = SendMessage(hwndOutput, WM_GETTEXTLENGTH, 0, 0);
SendMessage(hwndOutput, EM_SETSEL, textLen, textLen);
SendMessage(hwndOutput, EM_REPLACESEL, TRUE, (LPARAM)buffer);
SendMessage(hwndOutput, WM_VSCROLL, SB_BOTTOM, NULL);
}
sendData(buffer, strlen(buffer)+1, s);
|