char str[255]="";
GetCursorPos(&point);
HWND hwnd=(HWND)WindowFromPoint(point);
long i=GetWindowLong(hwnd,GWL_STYLE);//为什么获取总是0??我设置了password属性
if(i&ES_PASSWORD)
{
::SendMessage(hwnd,WM_GETTEXT,255,(LPARAM)str);
SetDlgItemText(IDC_EDIT1,str);
}char str[255]="";
GetCursorPos(&point);
HWND hwnd=(HWND)WindowFromPoint(point);
long i=GetWindowLong(hwnd,GWL_STYLE);
::SendMessage(hwnd,WM_GETTEXT,255,(LPARAM)str);
SetDlgItemText(IDC_EDIT1,str);
改成这样还是不能获取文本!
point的值不对,是相对的,不是绝对。
是相对于父窗体,如果是主窗体就是相对于荧屏,这往往就是错觉的来源。
The return value is a handle to the window that contains the point. If no window exists at the given point, the return value is NULL. If the point is over a static text control, the return value is a handle to the window under the static text control. hwnd 是指向IDC_EDIT1的嘛?
取出IDC_EDIT1 中的handle 和你的hWnd比较下吧 是否一致。