Как из скрипта узнать HWND окна IE?
Обратиться к window не помогает?
я все внимательно просмотрел, но так и не нашел
расшифруй hwnd, я такое сокращение раньше не встречал, мог просто неправильно понять )
Handle to a window.
Handle to Window - число идентифицирующее окно.
The GetActiveWindow function retrieves the window handle to the active window associated with the thread that calls the function.
HWND GetActiveWindow(VOID)
Parameters
This function has no parameters.
Return Values
If the function succeeds, the return value is the handle to the active window associated with the thread that calls the function.
If the calling thread does not have an active window, the return value is NULL.
либо же
IOleWindow::GetWindow
Returns the window handle to one of the windows participating in in-place activation (frame, document, parent, or in-place object window).
HRESULT GetWindow(
HWND * phwind //Where to return window handle
);
Parameter
phwnd [out] Points to where to return the window handle.
Return Values
S_OK
The window handle was successfully returned.
E_INVALIDARG
One or more arguments are invalid.
E_OUTOFMEMORY
Out of memory.
E_UNEXPECTED
An unexpected error occurred.
E_FAIL
There is no window handle currently attached to this object.
Comments
Five types of windows comprise the windows hierarchy. When a object is active in place, it has access to some or all of these windows:
Window Description
Frame The outermost main window where the container application's main menu resides.
Document The window that displays the compound document containing the embedded object
to the user.
Pane The subwindow of the document window that contains the object's view.
Applicable only for applications with split-pane windows.
Parent The container window that contains that object's view.
The object application installs its window as a child of this window.
In-place The window containing the active in-place object. The object application
creates this window and installs it as a child of its hatch window,
which is a child of the container's parent window.
Each type of window has a different role in the in-place activation architecture.
However, it is not necessary to employ a separate physical window for each type.
Many container applications use the same window for their frame, document, pane,
and parent windows.
а искать окно - до этого я и сам додумался, но это как-то коряво...
Если у объекта есть интерфейс IObjectWithSite и он создается через тег <object> то работает такой код:
STDMETHODIMP CMyControl2::get_HWND(LONG* pVal)
{
IOleWindow* pOW;
if(GetSite(IID_IOleWindow, (void**)&pOW)!=S_OK)
return E_FAIL;
else
{
HWND hWnd;
HRESULT r=pOW->GetWindow(&hWnd);
pOW->Release;
if(r!=S_OK)
return E_FAIL;
#pragma warning(push)
#pragma warning(disable:4311)
*pVal=(LONGvoid*hWnd);
#pragma warning(pop)
}
return S_OK;
}
может кому пригодится
Оставить комментарий
freezer
Есть html-страничка, там есть скрипт и еще создается COM-объект или с помощьюили
Объект самый простой, не OLE, только IUnknown, IDispatch, ITypeInfo и т.п. Как ему узнать HWND окна браузера в котором его создали?..