- IE内のスクロールバーの値は普通では取れないようだ。しょうがないので、マウスカーソル位置のHTMLエレメントを取得して、スクロール値を表示するようにした。ちょっといい加減だけど、まぁいいでしょう。以下抜粋。
[DllImport(FILE_NAME_USER32, SetLastError = true)]
public static extern uint RegisterWindowMessage(
string pString
);
[DllImport(FILE_NAME_USER32, SetLastError = true)]
public static extern int SendMessageTimeout(
IntPtr hWnd, // ウィンドウのハンドル
uint Msg, // メッセージ
IntPtr wParam, // メッセージの最初のパラメータ
IntPtr lParam, // メッセージの 2 番目のパラメータ
uint fuFlags, // 送信オプション
uint uTimeout, // タイムアウト期間
ref IntPtr lpdwResult // 同期呼び出しの戻り値
);
public const int SMTO_NORMAL = 0x0000;
public const int SMTO_BLOCK = 0x0001;
public const int SMTO_ABORTIFHUNG = 0x0002;
public const int SMTO_NOTIMEOUTIFNOTHUNG = 0x0008;
[DllImport("oleacc.dll", SetLastError = true)]
public static extern int ObjectFromLresult(
IntPtr lResult,
ref Guid riid,
IntPtr wParam,
ref IHTMLDocument2 ppvObject
);
以下本体
:
:
Guid IID_IHTMLDocument = typeof(IHTMLDocument2).GUID;
IHTMLDocument2 spDoc = new HTMLDocumentClass();
IntPtr lRes = IntPtr.Zero;
uint nMsg = RegisterWindowMessage("WM_HTML_GETOBJECT");
int result = SendMessageTimeout(fw, nMsg,
IntPtr.Zero, IntPtr.Zero,
(uint)SMTO_ABORTIFHUNG, (uint)1000, ref lRes);
if (result != 0)
{
int hr = ObjectFromLresult(lRes, ref IID_IHTMLDocument, IntPtr.Zero, ref spDoc);
if (hr == 0)
{
IHTMLWindow3 hw = spDoc.parentWindow as IHTMLWindow3;
IHTMLElement2 ele =
spDoc.elementFromPoint(Cursor.Position.X - hw.screenLeft,
Cursor.Position.Y + -hw.screenTop) as IHTMLElement2;
if (ele != null)
{
string pos = null;
pos += "V=" + ele.scrollTop + "/" + (ele.scrollHeight - ele.clientHeight);
pos += ",H=" + ele.scrollLeft + "/" + (ele.scrollWidth - ele.clientWidth);
showToolTip(pos, Cursor.Position);
processed = true;
}
}
}
: