如何区分句柄(10分)

  • 主题发起人 主题发起人 sy0116
  • 开始时间 开始时间
S

sy0116

Unregistered / Unconfirmed
GUEST, unregistred user!
用以下代码查找QQ聊天模式发送信息的richedit的句柄,找到两个,有什么办法能区分吗<br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; private<br><br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>function EnumAllWindow(hWnd:HWND; lParam:LPARAM): BOOL; stdcall;<br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br>function EnumAllWindow(hWnd: HWND; lParam: LPARAM): BOOL;<br>var<br>&nbsp; &nbsp;ClassName: Array[0..255] of char;<br>begin<br>&nbsp; &nbsp;GetClassName(hWnd,ClassName,255);<br>&nbsp; &nbsp;if ClassName = 'RICHEDIT' then<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; ShowMessage(IntToStr(hWnd));<br>&nbsp; &nbsp;end;<br>&nbsp; &nbsp;Result:=TRUE;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; &nbsp; &nbsp; &nbsp; hd, childhd: THandle;<br>begin<br>&nbsp; &nbsp; &nbsp; &nbsp; hd := FindWindow(nil, 'abcd');<br><br>&nbsp; &nbsp; &nbsp; &nbsp; if hd &lt;&gt; 0 then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; EnumChildWindows(hd, @EnumAllWindow, 0)<br>end;
 
这个窗口上很多其它特征。
 
拿Spy++分析一下
 
lich的方法,用SPY++可以得到两个richedit的class name分别为RICHEDIT和RichEdit20A<br><br>function EnumAllWindow(hWnd: HWND; lParam: LPARAM): BOOL;<br>var<br>&nbsp; ClassName: Array[0..255] of char;<br>begin<br>&nbsp; GetClassName(hWnd,ClassName,255);<br>&nbsp; if ClassName = 'RICHEDIT' then<br>&nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp;ShowMessage('接受信息框句柄:'+IntToStr(hWnd));<br>&nbsp; end;<br>if ClassName = 'RichEdit20A' then<br>&nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp;ShowMessage('发送信息框句柄:'+IntToStr(hWnd));<br>&nbsp; end;<br><br>&nbsp; Result:=TRUE;<br>end;<br>试试看如何
 
接受答案了.
 

Similar threads

后退
顶部