用spy++获取class名为Internet  Explorer_Server,然后我就无能为力了,怎样获得网页中文本框的句柄呢???比如说现在的网页为google

解决方案 »

  1.   

    Internet  Explorer_Server 这个东西到底是什么? 为什么我找不到里面的文本框?
      

  2.   

    you need to access IHTMLInputElement, some reference:
    http://blogs.msdn.com/rfarber/archive/2004/10/12/240943.aspx
    #  re: DrawToDC @ Tuesday, October 12, 2004 5:05 PM
    I tried this real quick and it works. I threw together a form with an IE control and a panel. There is an issue with import of the MSHTML interface so just redeclare it locally and you will have no problems. If render is null, you may have a frame to deal with.using System;
    using System.Drawing;
    using System.Runtime.InteropServices;
    using SHDocVw;
    using mshtml;namespace ScreenGrab
    {
    [
    Guid("3050f669-98b5-11cf-bb82-00aa00bdce0b"),
    InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown),
    ComVisible(true),
    ComImport
    ]
    interface IHTMLElementRender
    {
    void DrawToDC([In] IntPtr hDC);
    void SetDocumentPrinter([In, MarshalAs(UnmanagedType.BStr)] string bstrPrinterName, [In] IntPtr hDC);
    };public class IEElementCapture
    {
    private IWebBrowser2 webBrowser = null;public IEElementCapture(IWebBrowser2 webBrowser)
    {
    this.webBrowser = webBrowser;
    }public bool Capture(ref Graphics g)
    {
    if ( null == webBrowser )
    {
    return false;
    }IHTMLDocument2 htmlDocument = (IHTMLDocument2) webBrowser.Document;
    if ( null != htmlDocument )
    {
    IHTMLElement bodyElement = (IHTMLElement) htmlDocument.body;
    if ( null != bodyElement )
    {
    IHTMLElementRender render = (IHTMLElementRender) bodyElement;
    if ( null != render )
    {
    IntPtr memDC = g.GetHdc();
    render.DrawToDC(memDC);
    return true;
    }
    }
    }return false;
    }
    }
    }Darron