INT_PTR CALLBACK ConnectDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc = GetDC(hDlg);
int wmId, wmEvent;
static HWND hIpControl;
static HWND hPort;
static LPWSTR lpIPAddress = (LPWSTR)malloc(sizeof(LPWSTR));
static LPWSTR lpPort = (LPWSTR)malloc(sizeof(LPWSTR));
static char* IPArgtoFn;
static size_t IPAddressLength;
static size_t PortLength;
static POINT pt;
hIpControl = GetDlgItem(hDlg, IDC_IPADDRESS1);
hPort = GetDlgItem(hPort, IDC_EDIT2);
switch (message)
{
case WM_INITDIALOG:
{
return (INT_PTR)TRUE;
break;
}
case WM_COMMAND:
{
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
switch (wmId)
{
case IDCANCEL:
EndDialog(hDlg, wmId);
break;
case IDCONNECT:
IPAddressLength = GetWindowTextLength(hIpControl) + 1;
PortLength = SendMessage(hPort, WM_GETTEXTLENGTH, 0, 0);
GetWindowText(hIpControl, lpIPAddress, IPAddressLength);
pt.x = 10; pt.y = 10;
wcstombs(IPArgtoFn, lpIPAddress, IPAddressLength);
//TextOut(hdc, 10, 10, lpIPAddress , IPAddressLength);
mySocket.ConnectToServer(IPArgtoFn, (int)lpPort, hdc, pt);
return (INT_PTR)FALSE;
break;
default:
return DefWindowProc(hDlg, message, wParam, lParam);
break;
}
}
}
return (INT_PTR)FALSE;
}
I know I have the right control selected. Its identifier is IDC_EDIT2 and I know that is right. But whenever I try to retrieve the length of the edit control and save it to the variable PortLength, the value is always 0 when I debug it. I have already tried using GetWindowTextLength with works fine with the IP control but when I use it with the edit control, the length is always 0 no matter how long of a string I enter in the box.