老问题了,返回鼠标指针处控件的类名(30分)

  • 主题发起人 主题发起人 ouyongke
  • 开始时间 开始时间
O

ouyongke

Unregistered / Unconfirmed
GUEST, unregistred user!
我想把&quot;取密码过程&quot;合在一起用,可是没有改好,郁闷:<br>procedure TForm1.GetWindowText(HWnd:HWnd;GetPassWord:Boolean=False);<br>//取得文本且可以取得密码<br>var<br> iPwdChar &nbsp;: Integer;<br> iPwdLast &nbsp;: Integer;<br> psText &nbsp; &nbsp;: array[0..255] of char;<br> //psClass: String;<br> i &nbsp; &nbsp; &nbsp; &nbsp; : Integer;<br>begin<br> iPwdChar:=SendMessage(HWnd,EM_GETPASSWORDCHAR,0,0);<br> if (iPwdChar&lt;&gt;0) and GetPassWord then<br> begin<br> &nbsp; iPwdLast &nbsp;:= &nbsp;0;<br> &nbsp; i &nbsp; &nbsp; &nbsp; &nbsp; := &nbsp;0;<br> &nbsp; while iPwdLast=0 do<br> &nbsp; begin<br> &nbsp; &nbsp; PostMessage(HWnd,EM_SETPASSWORDCHAR,0,0);<br> &nbsp; &nbsp; Application.ProcessMessages;<br> &nbsp; &nbsp; Inc(i);<br> &nbsp; &nbsp; iPwdLast:=SendMessage(HWnd,EM_GETPASSWORDCHAR,0,0);<br> &nbsp; &nbsp; if i&gt;100 then break;<br> &nbsp; end ;<br> &nbsp; SendMessage(HWnd,WM_GETTEXT,255,Longint(@psText));<br> &nbsp; //Result:=psText;<br> &nbsp; Memo1.Text:= psText;<br> &nbsp; SendMessage(HWnd,EM_SETPASSWORDCHAR,iPwdChar,0);<br> end else begin<br> &nbsp; SendMessage(HWnd,WM_GETTEXT,255,Longint(@psText));<br> &nbsp; //Result:=psText;<br> &nbsp; Memo1.Text:= psText;<br> end;<br> //sendMessage(HWnd, WM_GETCLASSNAME,255,Longin(@psClass));<br> &nbsp;GetClassName(hWND,PChar(psClass),256); &nbsp; &nbsp; &nbsp;//HWIND2 mText<br> &nbsp;SetLength(psClass,StrLen(PChar(psClass))); &nbsp; &nbsp;//mText mText<br> &nbsp;Edit1.Text:= psClass;<br>end;<br>老东西就不给多少分了
 
Function GetMousePosClassName:ShortString;<br>var<br> &nbsp; &nbsp;hWnd: THandle;<br> &nbsp; &nbsp;aName: array [0..255] of char;<br> &nbsp; &nbsp;rPos: TPoint;<br>begin<br> &nbsp; &nbsp;if boolean(GetCursorPos(rPos)) then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;hWnd := WindowFromPoint(rPos); &nbsp;//句柄<br> &nbsp; &nbsp; &nbsp; &nbsp;if boolean(GetClassName(hWnd, aName, 256)) then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Result:= string(aName) &nbsp; &nbsp; //类名<br> &nbsp; &nbsp; &nbsp; &nbsp;else Result:='';<br> &nbsp; &nbsp;end<br> &nbsp; &nbsp;else Result:='';<br>end;<br><br>获得文字,用下句<br> &nbsp; &nbsp;SendMessage(hWndMouseOver, WM_GETTEXT, 255, LongInt(Text)); &nbsp;//设置内容
 
呵呵,就这个啦。<br>谢谢罗,其实我已经自己搞明白了,在这里多放几天,大家都来看看吧
 
后退
顶部