The SetFocus method changes focus to the browser control.
Parameters
None.
Return Value
If the method succeeds, the return value is non-zero. If the method
fails, the return value is zero. To get extended error information, call
GetLastError.
Remarks
The SetFocus method gives input focus to the
embedded browser control. Once focus has been set, keyboard input
such as typing or navigation keys will be directed to the content
displayed by the control rather than to other controls in the
host window. This is equivalent to the user clicking inside the
browser area.
Setting focus does not make the host window itself the active
foreground window. If the host window is not active, input will
still not be directed to the browser until the window is activated
by the user or programmatically. Applications that need to determine
whether the browser currently has focus can call GetFocus.
Example
BOOL bHasFocus = FALSE;
if (pWebView->GetFocus(&bHasFocus))
{
if (!bHasFocus)
{
pWebView->SetFocus();
}
}
else
{
DWORD dwError = pWebView->GetLastError();
_tprintf(_T("GetFocus failed, error=0x%lx\n"), dwError);
}
Requirements
Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: cshtmv12.lib
See Also
|