SendMessage无法再次SendMessage吗?咋一看,窗口过程没有返回,肯定是没法处理下一条消息.我差一点就把它作为结论记到笔记里了,但总觉得有点不对, 因此实验了下,结论是即使是对同一窗口过程,也是可以再次SendMessage的,也是说窗口过程是可重入的,如下 procedure wm_user3(var msg:TMsg); message wm_user+3; procedure wm_user4(var msg:TMsg); message wm_user+4; …… procedure TForm1.wm_user3(var msg:TMsg); var pt:Tpoint; x,y:integer; threadid:Cardinal; s:array[0..255] of char; h:THandle; begin GetCursorPos(pt); h:=WindowFromPoint(pt); x:=pt.X; y:=pt.Y; self.caption:='x='+inttostr(x)+' y='+inttostr(y)+' handle='+inttostr(h); FillChar(s,255,0); GetClassName(h,s,255); edt_winClass.Text:=StrPas(@s[0]); edt_formhandle.Text:=IntToStr(h); GetWindowRect(h,rect); edt_rect.Text:='left:'+inttostr(rect.Left)+',right:'+inttostr(rect.Right)+',width:'+inttostr(rect.Right-rect.Left)+',height:'+inttostr(rect.Bottom-rect.top); if (lstrcmp(s,'Internet Explorer_Server')=0) then begin Sleep(10); if iehandle<>h then begin iehandle:=h; GetIEFromHWND(iehandle,iewebbrowser); end; form1.edt_url.Text:=(iewebbrowser.LocationURL); Document:=iewebbrowser.Document as IHtmlDocument2; form1.edt_ihtmldcoument2.Text:=IntToStr(Integer(Pointer(document))); if Assigned(Document) then begin Form1.edt_formtext.Text:=Document.title; elem:=document.elementFromPoint(x-rect.Left,y-rect.Top); form1.edt_tagname.Text:=elem.tagName; Form1.edt_elemID.Text:=elem.id; form1.edt_elemtext.Text:=elem.innerText; form1.mmo1.Text:=elem.outerHTML; end; if tmr1.Enabled=False then tmr1.Enabled:=true; end else clear; end; procedure TForm1.tmr1Timer(Sender:TObject); begin SendMessage(Handle,wm_user+4,0,0); end; procedure TForm1.wm_user4(var msg:TMsg); begin SendMessage(Handle,wm_user+3,0,0); end;