Te dejo esto el proceso WndProc aun no lo pongo como miembro de la clase aun que sera facil tal cual a dicho Eternal Idol haciendo dicha funcion como Static ( yo mientras trabajare de esta manera para depurar mi codigo ).
Código
LRESULT CALLBACK WndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); cls_socket::cls_socket() { /* Constructor */ this->Event_RequestConection = NULL; this->Event_GetData = NULL; this->Event_Closed = NULL; this->Event_Connent = NULL; this->Event_Error = NULL; this->v_socket = INVALID_SOCKET; this->State = sckError; this->RemoteHost = NULL; this->RemotePort = 0; this->LocalPort = 0; if ( WSAStartup( MAKEWORD(2,2) , &this->v_wsadata ) != NO_ERROR ) return; this->v_hWinSock = CreateWindowExA( 0 , "STATIC" , "SOCKET_WINDOW",0, 0, 0, 0, 0, 0, 0, 0,NULL); if (this->v_hWinSock != NULL) if ( SetWindowLongA( this->v_hWinSock , GWL_USERDATA , (LONG)this ) == 0 ) if ( (this->v_PrevProc = SetWindowLongA( this->v_hWinSock , GWL_WNDPROC, (DWORD)WndProc)) != 0 ) { this->v_ItsOk = true; this->State = sckClosed; } } cls_socket::~cls_socket() { /* Destructor */ WSACleanup(); if ( this->v_PrevProc != 0 ) SetWindowLongA (this->v_hWinSock , GWL_WNDPROC, this->v_PrevProc); if ( this->v_hWinSock != NULL ) DestroyWindow (this->v_hWinSock); } LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { char *v_abuffer = NULL; char v_buffer[1024] = {}; int v_res = 0; unsigned int v_lenstr = 0; cls_socket *thisClass = NULL; SOCKET AceptSocket = INVALID_SOCKET; if ( uMsg != 1025 ) return DefWindowProc(hWnd, uMsg, wParam, lParam); /* Recuperamos la Clase */ thisClass = (cls_socket*)GetWindowLongA ( hWnd , GWL_USERDATA ); if ( thisClass == NULL ) return DefWindowProc(hWnd, uMsg, wParam, lParam); switch ( lParam ) { case FD_CONNECT: thisClass->State = sckConnected; /* Evento */ if ( thisClass->Event_Connent != NULL ) thisClass->Event_Connent ( thisClass ); break; case FD_READ: v_res = 0; v_lenstr = 0; do { v_res = recv( thisClass->v_socket , &v_buffer[0] , 1024 , 0 ); if ( v_res > 0 ) { v_lenstr += v_res; } } while ( v_res > 0 ); if ( v_lenstr > 0 ) { v_abuffer[v_lenstr] = '\0'; /* Evento */ if ( thisClass->Event_GetData != NULL ) thisClass->Event_GetData ( v_abuffer , v_lenstr , thisClass ); } // if break; case FD_WRITE: break; case FD_CLOSE: thisClass->State = sckClosed; closesocket( thisClass->v_socket ); thisClass->v_socket = INVALID_SOCKET; /* Evento */ if ( thisClass->Event_Closed != NULL ) thisClass->Event_Closed ( thisClass ); break; case FD_ACCEPT: //sockaddr SockAcept; if ( ( AceptSocket = accept( thisClass->v_socket , NULL , NULL ) ) != INVALID_SOCKET ) /* Evento */ if ( thisClass->Event_RequestConection != NULL ) thisClass->Event_RequestConection ( &AceptSocket , thisClass ); break; default: break; } // switch return 0; }
Temibles Lunas!¡.
.