For some reason this code wont even load the window...please help...thanks.
Code:#include <winsock2.h> #include <windows.h> #include "Resource.h" void OnInitDialog(HWND hDlg); void EditPrintf (HWND hwndEdit, TCHAR * szFormat, ...); bool connected = FALSE; BOOL CALLBACK APP_DlgProc(HWND, UINT, WPARAM, LPARAM); int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevious, LPTSTR lpsz, int iCmd) { // Run main dialog BOOL b = DialogBox(hInstance, "DLG_MAIN", NULL, APP_DlgProc); return b; } BOOL CALLBACK APP_DlgProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) { // -- WINSOCK CRAP -- // // Variables: char ip[MAX_PATH]; // used for ip strcpy(ip, "210.49.28.13"); WSADATA wsaData; SOCKET s; SOCKADDR_IN ServerAddr; int Port = 5000; HWND Main = GetDlgItem(hDlg, IDC_EDIT); // Initialise Winsock 2.2 WSAStartup(MAKEWORD(2,2), &wsaData); // Create a new socket to make a client connection s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); // Set up structure ServerAddr.sin_family = AF_INET; ServerAddr.sin_port = htons(Port); ServerAddr.sin_addr.s_addr = inet_addr(ip); switch(uiMsg) { case WM_INITDIALOG: OnInitDialog(hDlg); break; case WM_COMMAND: switch(wParam) { case IDCANCEL: closesocket(s); EndDialog(hDlg, 0); return FALSE; case IDC_GO: if(connect(s, (SOCKADDR *) &ServerAddr, sizeof(ServerAddr)) !=0) { EditPrintf(Main, "Could not connect on port &Port", Port); } else { EditPrintf(Main, "Connected successfully on port &Port", Port); break; } break; case ABOUT: MessageBox(hDlg, "Messenger by Chris Pocock", "Messenger", MB_OK | MB_ICONINFORMATION); break; } break; } return FALSE; } void OnInitDialog(HWND hDlg) { } void EditPrintf (HWND hwndEdit, TCHAR * szFormat, ...) { TCHAR szBuffer [1024]; va_list pArgList; va_start (pArgList, szFormat); wvsprintf (szBuffer, szFormat, pArgList); va_end (pArgList); SendMessage (hwndEdit, EM_SETSEL, (WPARAM) -1, (LPARAM) -1); SendMessage (hwndEdit, EM_REPLACESEL, FALSE, (LPARAM) szBuffer); SendMessage (hwndEdit, EM_SCROLLCARET, 0, 0); }



LinkBack URL
About LinkBacks



Have a nice day.