鼠标滚轮消息,对Memo控件有效果。对webbrowser控件没效果,帮个忙试试!
这代码很多人需要吧,网上很难找。
虽然webbrowser不起效,其它控件还是有用的。谁帮试试!
- Delphi(Pascal) code
function TForm1.GetHwnd(AHwnd:THandle):THandle;begin //Result := FindWindowEx(ParentHwnd, 0,'Shell Embedding', nil); Result := FindWindowEx(AHwnd, 0,'Shell DocObject View', nil); Result := FindWindowEx(Result, 0,'Internet Explorer_Server', nil);end;procedure TForm1.Button1Click(Sender: TObject);begin SendMessage(GetHwnd(EmbeddedWB1.Handle), WM_MOUSEWHEEL, (-120*3) shl 16, (5 shl 16) or 5);//失败 //SendMessage(Memo1.Handle), WM_MOUSEWHEEL, (-120*3) shl 16, (5 shl 16) or 5);//成功end;
[解决办法]
IHTMLWindow2(IHTMLDocument2(WebBrowser1.Document).ParentWindow).Focus;
IHTMLWindow2(IHTMLDocument2(WebBrowser1.Document).ParentWindow).scroll(100,100);
用这个吧,效果一样的,直接鼠标消息那个我也没做出来,放弃了,呵呵