You are typecasting the TCHAR[]
itself to an HWND
. That will never work. You need to extract the TCHAR[]
text from the edit control, then use _stscanf()
or similar parsing function to convert that text value to an integer which can be typecasted to an HWND
, then assign your other text to that HWND
as needed.
For example:
void ChwndtestDlg::OnBnClickedButton1()
{
CString sWnd;
if (GetDlgItemText(IDC_HWNDEDIT, sWnd) > 0)
{
HWND hWnd;
if (_stscanf((LPTSTR)sWnd, _T("%p"), &hWnd) == 1)
{
CString sText;
GetDlgItemText(IDC_TEXTEDIT, sText);
::SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)(LPTSTR)sText);
}
}
}